Repository navigation
Conversation
The TSX projection of a module with `export default component` now ends with a default export typed as the prelude's `Main`, a function of the app giving the view `app.mount` takes, as the compiled `main(__rt)` is. A `.d.rx` that a tsconfig's `include` picks up becomes an empty module in the language plugin instead of a file with no script.
brenelz
marked this pull request as ready for review
November 14, 2026 02:58
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A TypeScript entry written as the README shows (
import main from "./app.rx"; app.mount(main(app))) failsrx-tsc --noEmitwithTS1192: Module './app.rx' has no default export. Separately, with"include": ["src"]and a.d.rxinsrc/,rx-tsccrashes withlanguageId not found for …/users.d.rxand thenError: !!sourceScriptfrom Volar'sproxyCreateProgram.Root cause
The TSX projection (spec/13 TY-1c) emits the default component as
export function App(props: any)plusexport const __view, and nothing as a default export. At run time the compiled entry's default export ismain(__rt)(spec/11 CP-4a), so TypeScript sees no default where JavaScript gets one. For the crash:.rxis a program extension, soincludeglobs also match.d.rx. The language plugin returned no language id for those files, and Volar's tsc asserts that every program file has a source script.What changed
export type Main = (app: object) => () => View;, a function of either build'screateAppapp that gives the viewapp.mount(or the server'sapp.stream) takes. A module withexport default componentnow ends its projection withdeclare const __main: __.Main; export default __main;. The line is appended after the existing output, so the component's own mappings are unchanged. The type is in the prelude rather than taken from@reactivescript/runtime, because the prelude must resolve without the runtime installed (ref's type runner has no copy), andcreateApp's declared return type does not list the__rthelpers anyway.compiler/src/project.rs,prelude.ts) and ref (ref/types/project.ts) make the same change, sincecrate.ts --projectcompares them text for text..d.rxits own language id and an empty TypeScript module (export {}), so a.d.rxthatincludepicks up no longer stops the program.compiler/src/prelude.tsline 12 still had the\`` escapes copied from ref's template literal, socrate.ts --projectfailed onmainwithFAIL prelude`. The fix changes only a comment.Verification
cargo test --releaseincompiler/: a new test checks that an entry's projection has exactly one default export, thatAppkeeps its mapping, and that a dependency without a default component gets no default export.node test/tsc.jsintooling/rx-language-server/(now also needsnpm run buildinruntime/). New checks:src/main.jssnippet, read fromREADME.md, type-checks against the built runtime's types;app.stream(main(app), sink)type-checks with the server build;app.mount(main), withmainuncalled, fails with TS2345;.d.rxand the JS module it declares pass with"include": ["."].npm testintooling/rx-language-server/: 16/16 and 8/8.ref/:npm run crate: 364/364.npm run crate -- --project: 209/209, with 12,421 mappings holding.npm run typesandRX_CRATE=1 npm run types: 176 pass each.npm test: no failures.@ts-expect-errorlines and its"exclude": ["src/**/*.d.rx"]removed, passesrx-tsc --noEmitwith this branch. It crashes with the published 0.3.1.Left open
.rxfiles (NOT_EXPORTED, MO-6), but MO-1c says a dependency may have a default component. If that import is ever allowed, the importer's projection should name the component (import { Badge as Tag }).default, yet the projection still exportsexport component Fooand other named exports, so JavaScript can import names that do not exist at run time.maindefault, but its projection has none.Maintakes anyobject; a narrower type needs an app type exported from the runtime..rx, so go-to-definition on the importedmainlands nowhere..d.rx's own types are not checked; projecting it through the crate'sdeclaration_filewould check them, but with no mappings back.🤖 Generated with Claude Code