<!--{ "pin": "bottom", "order": 2 }-->

# TJS findings

tosijs-native is the first project written natively in `.tjs` from scratch (tjs-lang 0.14.1
since 2026-12-03, 0.14.0 and rc.9 before; tosijs-ui 1.20.1, Bun 1.4.2), and Longtime Listener,
an app built on it, the second (below: [A second project](#a-second-project-an-app-2026-12-04)).
The owner's question
was whether that is viable, or whether to switch to Bun + TypeScript and file the issues. This
file is the evidence. Each finding was reproduced in isolation and is filed on the virta board
(task numbers in brackets). Dogfooding tjs-lang as it approaches 1.0 is worth doing for its own
sake, so the aim is to overcome these, not just record them: when one is fixed upstream, retire
its workaround here and strike the finding.

## Verdict

**Viable**, now for an app as well as a library. Authoring, running, testing, linting and
documenting `.tjs` all work, with no workarounds left in this project's code. Of the 33
findings (30 on tjs-lang, 3 on tosijs-ui), 30 are fixed upstream, most within a day of their filing: 0.14.0 fixed the first
sixteen, 0.14.1 (2026-12-03) the linter, codegen and test findings that 0.14.0's new linter
brought out, and main (unreleased after 0.14.2) the `mock` block (31), three hours after it was
filed. `bun run check` is plain `tjs check src --max-warnings 0` again.

Open: the published types (28), and a name that is never declared passing `tjs check` (32),
which cost the second project a crash at start that check had passed; and on tosijs-ui, an
icon's style fill dropped silently (33).

What remains is the published types (28): **generated `.d.ts` is still too coarse to publish**,
so `src/index.d.ts` stays hand-written, guarded by `src/exports.test.ts` and `bun run
typecheck` (a TypeScript consumer, `types/consumer.ts`, compiles against `dist/`). That's an
accepted state for now. TJS's primary goal is to replace TypeScript with JavaScript as it
should be; emulating TypeScript is secondary (the owner, 2026-12-02). The aim is the finessed
types written in the TJS source, with the `.d.ts` generated from them: precise types the author
states in TJS, not perfect inference.

## What worked

- `bun test` imports `.tjs` through the `tjs-lang/bun-plugin` preload (`bunfig.toml`) with
  no further setup. Tests stay `.test.ts`, because `bun test` does not discover `.test.tjs`.
  Since 0.14.1 a test block runs with its imports and `tjs test` runs `.test.tjs` files, so the
  contract suite could move into `.test.tjs` (not done yet: it would add a lane beside `bun
  test`).
- Validation at the boundaries came free and is the right shape: a bad config or bridge
  is refused at the call (`defineConfig`, `createNative`) with a `MonadicError`, which
  `extends Error`, and since 0.14.0 it names the failing field (`call: expected function, got
  number`). The internals are unvalidated closures.
- `Is` / `IsNot` replaced a hand-written deep-equal in the contract suite.
- `/*# … */` blocks in `.tjs` become tosijs-ui doc pages, and `tjs emit` writes `.md` from
  the same blocks.
- `Bun.build` with `tjs-lang/bun-build-plugin` (0.14.0) bundles the graph into
  `dist/index.js`, which plain Node imports with no TJS installed. With `sharedPrelude` the
  bundle carries one TJS runtime.

## Open

32. **`tjs check` passes a name that is never declared.** [#4735] Reproduced on 0.14.1 and on
    main (2026-12-04): a misspelt local (`return summ` beside `let sum`) and a build-time
    define a build forgot (`TESTR`) both get ✓, and each throws `ReferenceError` the first time
    it runs. A signature example catches one only on the paths it walks, and a `:!` return runs
    none. Longtime Listener's dev server, started before its `TESTER` define existed, served an
    app that died at start after `tjs check src --max-warnings 0` had passed. Suggested: a
    no-undef rule against the file's declarations, its imports and the target's globals, and a
    way to declare build-time globals with an example value, so they are typed too.

28. **Generated `.d.ts` is too coarse to replace a hand-written file.** [#4569] Re-measured on
    0.14.1 (2026-12-03): `tjs emit src --dts` writes 166 lines against 664 hand-written, and
    `types/consumer.ts` gets 16 errors against them (17 on 0.14.0). The predicate-only `Type`
    import that stopped it compiling at all is fixed (#4568), as are async returns, optional
    members, descriptions and typed arrows in examples (#4590, #4591, #4592, #4586). What is
    left: `createNative` returns `Promise<Record<string, any>>`, so every call on the API is
    unchecked (the consumer's five `@ts-expect-error` lines go unused); the status lists are
    `any[]`, so no `PurchaseStatus` or `LocationStatus` union can be derived from them; and
    `NativeConfig` lacks `capabilities`. The first is this project's to state: the `Native`
    API as a TJS `Type` with typed arrow members, which 0.14.1 can now carry to the `.d.ts`. The
    others wait on #4569 (typed constants, a type derived from a list). Overloads keyed by an
    event name (`on('pause', …)`) wait on a language decision [#4593]. When `types/consumer.ts`
    compiles against the generated file, `src/index.d.ts` goes.

## Fixed on main (after 0.14.2, unreleased)

31. ~~**A documented `mock { }` block is a parse error in `tjs check`.**~~ [#4719] Filed from
    Longtime Listener at 09:37 on 2026-12-04, fixed upstream at 12:27 (one recognizer for test
    blocks in `parse()` and `tjs()`; on the way, `class Latest { }` and `class Unmock { }` had
    been losing their bodies in plain `.js` too). Verified on main with the repro and a control
    (a mock test that should fail still fails). Until the release, the second project's shared
    feed fixtures live in a `bun test` file.

## Fixed in 0.14.1 (2026-12-03)

17. ~~**Exported declarations are reported unused, and `Type` desugaring is linted.**~~ [#4233]
22. ~~**no-explicit-new tells you to drop `new` on built-ins, where doing so throws or changes
    meaning.**~~ [#4562] The rule is retired. The 66 `new Error(…)` that became `Error(…)` stay
    as they are: both forms agree.
23. ~~**no-unused-vars resolves a use against every scope in the file.**~~ [#4563]
24. ~~**safe-assign makes a nullable `let` impossible.**~~ [#4565] A `let x: T | null` may be
    cleared, and the annotation's status is settled [#4588].
25. ~~**No way to configure or suppress a rule.**~~ [#4566] `// tjs-ignore <rule>: <reason>`,
    and `tjs check --json` gives each diagnostic a code and a line [#4585]. With 22–25 fixed
    the wrapper that filtered the linter's false positives, `bin/check.ts`, is gone.
19. ~~**`Date.now()` warns while calling itself safe.**~~ [#4237] The `wallClock` stand-in is
    gone from five files.
20. ~~**`await` on the right of `&&` or `||` emits JavaScript that does not parse.**~~ [#4238]
    `return (await a()) && (await b())` runs, and `tjs()` now parses its own output, so the
    class fails at transpile time. The await-into-a-variable notes are gone.
26. ~~**Line numbers drift after a typed parameter list spread over several lines.**~~ [#4564]
27. ~~**`tjs run` cannot import an exported `Type` from another file.**~~ [#4567]
29. ~~**A test block that uses an import cannot run in the pass.**~~ [#4583]
30. ~~**`Date(x)` gets past the raw-Date refusal.**~~ [#4584] It warns now, and names
    `LegacyDate(x)` for a real Date.

## Fixed in 0.14.0 (2026-10-31 upstream; adopted here 2026-12-02)

1. ~~**`tjs emit --dts` drops re-exports.**~~ [#3587]
2. ~~**Types imported from another file become `any` in `.d.ts`.**~~ [#3588]
3. ~~**A `Type` used inside another `Type`'s example becomes `any[]`.**~~ [#3589]
4. ~~**A `null` dictionary-default member is typed `null` in `.d.ts`.**~~ [#3590]
5. ~~**`tjs emit` leaves `./x.tjs` import specifiers unrewritten.**~~ [#3592] The package
   still ships one bundle, which is what an app wants anyway.
6. ~~**No `Bun.build` plugin ships.**~~ [#3593] `tjs-lang/bun-build-plugin`; its output was
   byte-identical to ours, and `bin/tjs-build-plugin.ts` is gone.
7. ~~**The runtime prelude is inlined once per module.**~~ [#3594] `sharedPrelude: true`
   (`tjsBundler` in `bin/build.ts`). See 21 for the numbers.
8. ~~**A `Type` example with function-valued members rejects every value.**~~ [#3595] `Bridge`
   is declared by example, and the bridge constructors return `:! Bridge`.
9. ~~**A dictionary default cannot have an `undefined` member.**~~ [#3591]
10. ~~**A typed parameter with a default is a parse error.**~~ [#3596]
11. ~~**Errors for a nested mismatch don't say where.**~~ [#3597]
12. ~~**Class constructor parameters are not validated.**~~ [#3598]
13. ~~**Return examples are only tested by `tjs check`.**~~ [#3599] Now an opt-in
    (`TJS_RUN_TESTS=1`, or `runTests` on the plugins). This project keeps `check` as the lane
    that runs them.
16. ~~**A parameter defaulting to `null` accepts only `null`.**~~ [#3609]

## Suggestions filed (2026-12-02)

What would make the toolchain one round wheel, from this project's experience:

- One command for a whole project, with a table of each lane and what removes it [#4589]:
  on 0.14.1, `check` and tests are done, types are the rest of #4569, formatting is after 0.14
  (#2170, #2165), and the bundle default waits on a tree-shakable prelude.
- JSON diagnostics, each with a line and a rule id [#4585]: shipped in 0.14.1.
- TJS-typed arrow functions in examples, so an API object's methods reach `.d.ts` [#4586]:
  shipped in 0.14.1.
- The shared prelude as the `Bun.build` default [#4587]: measured upstream, and it would
  enlarge most bundles (gzip absorbs small inline copies) until the prelude is tree-shakable
  (#3610).
- Deciding whether a `let`'s annotation is enforced or documentation [#4588]: settled in 0.14.1.
- Evidence and design points for the frozen formatter cards (#2170, #2165), gofmt's model: no
  options, no reflow, a before/after program comparison, made possible by TJS's newline rule,
  which removes the need for semicolons.

## A second project: an app (2026-12-04)

Longtime Listener, the owner's podcast player (closed source, so described here, not quoted),
was written in `.tjs` from an empty repo to an app on two iPhones, an Android phone and a Mac
in about three and a half hours: 15 modules, about 3,900 lines, a pure core (feed parsing, the
listening rules, the cache planner, promotion detection, the library file and its merge) under
a tosijs and tosijs-ui interface, bundled by `Bun.build` with `tjs-lang/bun-build-plugin` and
run in WKWebView, Android's WebView and Chrome. It used tjs-lang 0.14.1.

- **The lanes held.** `tjs check src --max-warnings 0` ran 28 inline `test` blocks and every
  signature example on each change; 19 `bun test` cases (the player against stand-in audio
  elements, the shelf, two devices' library files) ran through the preload. No `tjs-ignore` was
  needed.
- **Examples caught the author.** Several wrong signature examples (a cache plan's expected
  size, what is culled, a slug) failed `check` while writing, before anything ran, which is the
  point of a colon value being a worked example. A test block beside the function it tests
  (measuring what a kept part of an MP3 holds; parsing a Content-Range) kept each rule next to
  its code.
- **What got in the way:** the `mock` block (31, now fixed on main) and an undeclared name
  passing check (32). Nothing else: no type gymnastics, no build plugin of its own, no
  `.d.ts` (an app publishes none, so 28 does not touch it).
- **Lessons that were not TJS's:** WebKit hangs a seek made before an audio element's first
  play, and draws Apple's lock screen from the page's own media session; both are written up in
  tosijs-native's media docs.

## Not tjs-lang (tosijs-ui)

33. **A fill or stroke given in an icon's style is dropped silently.** [#4736] Reproduced on
    1.20.1 (and the same code on main): `icons.star({ style: { fill: 'red' } })` comes back
    with `fill: var(--tosi-icon-fill, none)`, because the icon's own fill and stroke are set
    after the caller's props. The documented ways work (`--tosi-icon-fill`, or a `_FF9500F`
    suffix), and Longtime Listener's favourite star uses the variable.

14. ~~**`buildSite` needs `happy-dom`, which tosijs-ui declares as an *optional* peer.**~~ [#3600]
    Fixed in tosijs-ui 1.17.0: the build stops before writing anything and prints the install
    command.
15. ~~**tosijs-ui scrapes `/*# … */` doc blocks, not TJS's own `/# … #/`.**~~ [#3601] Fixed in
    tosijs-ui 1.17.0, using tjs-lang's grammar to find them (`findDocCommentSpans`, which
    tjs-lang 0.14.0 exports). This project still writes `/*#` blocks, which also work.
18. ~~**A relative `logo` path breaks the header on every nested page.**~~ [#3926] Fixed in
    tosijs-ui 1.19 (the path is made root-absolute at build time); the inline-SVG
    workaround is gone.

## 21. The TJS runtime's share of an app's bundle

**Measured 2026-11-25** (#4272) on rc.9: the runtime `tjs` emits at the top of each module
(`__tjs_rt`: monadic errors, type checks, value descriptions) was 37,991 bytes of a
200,908-byte bundle, and the `__tjs` metadata on functions another 11,195.

**Measured 2026-12-02** on 0.14.0, what an app ships (`index.js` and the chunks it imports,
not the contract suite):

| build | raw | minified | minified, gzip |
|---|---|---|---|
| a runtime per module (our old plugin, or theirs by default) | 207,723 | 119,948 | 33,793 |
| `sharedPrelude` (what `bin/build.ts` now does) | 174,023 | 98,153 | 28,441 |

Not a blocker; a cost to weigh against the checks it buys. tjs-lang's `docs/shared-runtime.md`
proposes one runtime shared by many published libraries, after 1.0.
