Elegant
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.
How the tools read Ljós
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.
The language server
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:
Shell
Copy
ljos lsp
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:
Text
Copy
vim.lsp.config("ljos", {
  cmd = { "ljos", "lsp" },
  filetypes = { "qml", "typescript" },
  root_markers = { "tsconfig.json", "qmldir", ".git" },
})
vim.lsp.enable("ljos")
In Helix, in languages.toml:
TOML
Copy
[language-server.ljos]
command = "ljos"
args = ["lsp"]

[[language]]
name = "qml"
language-servers = ["ljos"]

[[language]]
name = "typescript"
file-types = ["ts", "mts", "cts", "lts"]
language-servers = ["typescript-language-server", "ljos"]
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.
.lts modules and stock TypeScript
An .lts module is imported as a .ts one is, from QML and from other modules, and values and types cross both ways:
width.lts
TypeScript
Copy
export type Width = 1 | 3
export function width(thick: boolean): Width {
    return match (thick) {
        when true: 3;
        when false: 1;
    }
}
line.ts
TypeScript
Copy
import { type Width, width } from "./width.lts"
export function total(): number {
    const thin: Width = width(false)
    return thin + width(true)
}
TypeScript
Copy
export type Width = 1 | 3
export function width(thick: boolean): Width {
    return match (thick) {
        when true: 3;
        when false: 1;
    }
}
Edit
Source
What this example draws
What this example draws
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 *.
Text
Copy
// Generated by ljos check from width.lts; do not edit.
export type Width = 1 | 3;
export declare function width(thick: boolean): Width;
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:
JSON
Copy
{
  "extends": "./.ljos/tsconfig.base.json"
}
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:
Shell
Copy
ljos migrate --write .
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.
Checking with TypeScript itself
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:
Shell
Copy
ljos check --tsc .
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:
Text
Copy
line.ts:3:21: error: `thin` is `1`; this gives it `1 | 3` [ts-assign-type]
line.ts:3:11: error: Type 'Width' is not assignable to type '1'. [TS2322]
3 files, 2 errors, 0 warnings
ljos: 2 errors
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.
See also
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.
How the tools read Ljós
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.
The language server
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:
Shell
Copy
ljos lsp
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:
Text
Copy
vim.lsp.config("ljos", {
  cmd = { "ljos", "lsp" },
  filetypes = { "qml", "typescript" },
  root_markers = { "tsconfig.json", "qmldir", ".git" },
})
vim.lsp.enable("ljos")
In Helix, in languages.toml:
TOML
Copy
[language-server.ljos]
command = "ljos"
args = ["lsp"]

[[language]]
name = "qml"
language-servers = ["ljos"]

[[language]]
name = "typescript"
file-types = ["ts", "mts", "cts", "lts"]
language-servers = ["typescript-language-server", "ljos"]
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.
.lts modules and stock TypeScript
An .lts module is imported as a .ts one is, from QML and from other modules, and values and types cross both ways:
width.lts
TypeScript
Copy
export type Width = 1 | 3
export function width(thick: boolean): Width {
    return match (thick) {
        when true: 3;
        when false: 1;
    }
}
line.ts
TypeScript
Copy
import { type Width, width } from "./width.lts"
export function total(): number {
    const thin: Width = width(false)
    return thin + width(true)
}
TypeScript
Copy
What this example draws
What this example draws
Edit
Source
export type Width = 1 | 3
export function width(thick: boolean): Width {
    return match (thick) {
        when true: 3;
        when false: 1;
    }
}
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 *.
Text
Copy
// Generated by ljos check from width.lts; do not edit.
export type Width = 1 | 3;
export declare function width(thick: boolean): Width;
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:
JSON
Copy
{
  "extends": "./.ljos/tsconfig.base.json"
}
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:
Shell
Copy
ljos migrate --write .
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.
Checking with TypeScript itself
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:
Shell
Copy
ljos check --tsc .
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:
Text
Copy
line.ts:3:21: error: `thin` is `1`; this gives it `1 | 3` [ts-assign-type]
line.ts:3:11: error: Type 'Width' is not assignable to type '1'. [TS2322]
3 files, 2 errors, 0 warnings
ljos: 2 errors
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.
See also