Editor Setup
Connect an editor to ljos lsp, let stock TypeScript tools read
.lts modules, and check scripts with TypeScript itself through
ljos check --tsc.
This page shows you how to connect your editor to
ljos lsp, how a .ts module and the tools that read it see an .lts module, and how to have TypeScript itself check your scripts with ljos check --tsc.A QML file's scripts and an
.lts module can use syntax that TypeScript does not have: match and is. Every tool that reads a script reads it with that syntax compiled away into plain TypeScript, line for line, and reports what it finds at its place in the file you wrote:ljos check, and ljos check --tsc, which gives the compiled text to TypeScript too;ljos lsp, the language server your editor talks to;the authoring MCP server's
qml_check and qml_lint, for coding agents.A
.ts module stays plain TypeScript, so that tsc, tsserver and every editor read it as they read any other. A module that uses the new syntax ends in .lts.ljos lsp speaks the language server protocol over standard input and output. Point your editor at it for QML files and for .ts and .lts modules:It takes the project from the editor's workspace folder. For each open file it publishes what the compiler finds, on open and on each change, from the text in the editor rather than the file on disk; keystrokes that come faster than it checks are checked once, as the last one left the text. When you save a file it checks every open file again, so a file that imports the one you saved sees the change. Between messages it waits; it does not watch or poll anything.
In Neovim, with the built-in client:
In Helix, in
languages.toml:Helix takes each key you give a language in place of its own, so the
typescript entry lists the server and file types Helix already has for TypeScript as well as ljos and lts.Any other editor that runs a language server as a command takes the same
ljos lsp. An .lts file is TypeScript to an editor's highlighter: map the lts extension to TypeScript.What the server does for you:
Findings where you type. A type error after a
match is shown on its own line and column, not on the line the compiled text would put it.The rename to
.lts. A .ts module that uses match or is is the error ts-lts-syntax. The server offers the fix as a code action: it renames the file to .lts and rewrites every import that names it.Fresh declarations. Saving an
.lts module writes its declaration again, so the .ts files that import it see the change at once.Lints and
--tsc stay with ljos check, so a keystroke never waits on TypeScript.An
.lts module is imported as a .ts one is, from QML and from other modules, and values and types cross both ways:tsc cannot read width.lts, but it can read its declaration. ljos check writes one for every .lts module into the project's .ljos/ directory: .ljos/types/width.d.lts.ts, with only the module's types in it. It writes a file only when its text changes, and deletes one only when its module is gone. .ljos/ holds nothing but generated files and a .gitignore of *.So that a declaration can say what a module exports without type-checking the module, every export of an
.lts module states its type: a function's parameters and result, and a const whose type is not plain from its value. One without is the error lts-export-type.The project's
tsconfig.json points TypeScript at the declarations by extending the base ljos check writes next to them:The base turns on
allowArbitraryExtensions and adds .ljos/types to rootDirs, so import … from "./width.lts" resolves to the declaration and the specifier stays as you wrote it. When a project with an .lts module has no tsconfig.json, or has one that does not extend the base, ljos check warns tsconfig-lts, and ljos migrate --write makes the least edit that fixes it, keeping the file's other keys and comments:ljos check finds the project root as --project <dir>, or else the nearest directory upward with a tsconfig.json, or else the deepest directory that holds every file checked. ljos types . writes the same declarations without checking anything else.ljos check types your scripts with its own checker. --tsc gives them to TypeScript as well, compiled, with every .lts module's declaration built in memory, and reports TypeScript's findings at their place in your files:Were
line.ts to declare const thin: 1 = width(true), both checkers would say so, each at the place in line.ts, and TypeScript's finding ends with its own code:It runs
deno check, or the tsc that the LJOS_TSC environment variable names. Without either it says SKIPPED: no tsc and checks as it would without --tsc.
