--- title: "One TypeScript checker for your editor, terminal, and agent" author: "@chris" author_url: https://elements.dev/u/@chris published: 2026-12-02T04:45:01.905Z url: https://elements.dev/blog/one-typescript-checker-for-your-editor-terminal-and-agent-j6ru8edi kind: post format: video video: https://elements.dev/blog/one-typescript-checker-for-your-editor-terminal-and-agent-j6ru8edi/video.mp4 poster: https://elements.dev/blog/one-typescript-checker-for-your-editor-terminal-and-agent-j6ru8edi/poster.jpg duration: "5:25" transcript_vtt: https://elements.dev/blog/one-typescript-checker-for-your-editor-terminal-and-agent-j6ru8edi/transcript.vtt --- # One TypeScript checker for your editor, terminal, and agent by [@chris](https://elements.dev/u/@chris) ยท 2026-12-02 ## Description The Elements build server runs the TypeScript type checker inside the build server process. When you save a file, the build server runs a build, and that build type checks the file you saved. If the file you saved runs on the server and in the browser, the build server type checks it twice: once against the lib list for the server and once against the lib list for the browser. You set both lib lists in config.jsoc, the project's config file. In the video, the build server's log shows the six most recent builds of the demo app taking 3 to 6 milliseconds each. The build server sends the same type errors to your editor, to your terminal and to elements build -json, the command an agent runs. That command asks the build server for the errors from the last build, and the build server answers in microseconds. In most TypeScript projects, your editor starts its own TypeScript server, your agent runs tsc, your bundler removes the type annotations without type checking your code, and your CI system runs tsc again. We designed Elements to have one program type check your code: the build server. Microsoft rewrote the TypeScript compiler in Go, and Elements is written in Go too. So the TypeScript compiler's Go source code is compiled into the Elements build server. We added two languages to the TypeScript compiler in Elements: reactive HTML, our HTML language, and JSOC, our config language. A reactive HTML file has plain HTML tags, with TypeScript expressions in a tag's attributes and in its body. The type checker that checks TypeScript files also type checks the TypeScript expressions in a reactive HTML file. A TypeScript file can import a .jsoc file, and the same type checker reports a type error when the TypeScript file reads a key that the .jsoc file does not have. Elements is the build server for web apps, built for humans and their AI agents. It is a build server, an app framework, a Postgres database and deployment, engineered as one system. ## Notes In this video we show how the Elements build server type checks TypeScript. The Elements build server runs the TypeScript type checker inside the build server process. When you save a file, the build server runs a build, and that build type checks the file you saved. The build server sends the same type errors to your editor, to your terminal and to `elements build -json`, the command an agent runs. In the video we edit the code of a demo app. We pass a number to a function that takes a string. We add a function that calls `toSorted`, which was added to JavaScript in ES2023, to a file that runs on the server and in the browser. The build server type checks that file twice: once against the library types that the `lib` option lists for the server, and once against the library types that the `lib` option lists for the browser. The demo app's `config.jsoc`, the project's config file, sets `lib` to ES2023 for the server and ES2020 for the browser, so the `toSorted` call is a type error for the browser only. The demo app's home page is a reactive HTML file. Reactive HTML is our HTML language: plain HTML tags, with TypeScript expressions in a tag's attributes and in its body. The home page imports a variable named `greeting` from a TypeScript file and prints the value of `greeting`. We misspell `greeting` in the home page, and the build server reports a type error. Then we explain which files the build server type checks after you save a file. ## One Type Error in the Editor, the Terminal and the `elements build` Command an Agent Runs The demo app in the video has a TypeScript file, `app/shared/greet.ts`, with one function, `greet`, and one call to `greet`: ```ts app/shared/greet.ts export function greet(name: string): string { return "Hello, " + name; } export let greeting = greet("Ada"); ``` `greet` takes a string. On line 5 we pass `greet` a number: ```ts app/shared/greet.ts export let greeting = greet(42); ``` Passing a number to `greet` is a type error, and the editor underlines `42`. We save `greet.ts`, and the Elements build server runs a build. The build server type checks `greet.ts`. `elements start` is running in a terminal. `elements start` connects to the build server and runs the demo app. After each build, `elements start` prints `State: Ok` or `State: Error`, and under `State: Error` the errors from that build. After the build that ran when we saved `greet.ts`, `State: Ok` changes to `State: Error`, and `elements start` prints the type error:   To read the errors from the last build, an agent runs `elements build -json`. In the video we run `elements build -json` in a second terminal: ```bash Terminal elements build -json ``` The build server returns the same type error, and the `elapsedSeconds` field says the build server answered in microseconds: ```json "elapsedSeconds": 0.000001, "diagnostics": [ { "code": 2345, "level": "error", "message": "Argument of type 'number' is not assignable to parameter of type 'string'.", "path": "app/shared/greet.ts", "loc": { "start": 104, "finish": 106, "line": 5, "column": 29 }, "modes": [ "types" ] } ] ``` One program, the build server, sent that type error to the editor, to `elements start` in the first terminal and to `elements build -json` in the second terminal. The `elements build -json` command did not run the type checker again. It asked the build server for the errors from the last build. We change `42` back to `"Ada"` and save `greet.ts`. The editor removes the underline, and `elements start` prints `State: Ok` in place of `State: Error`. We run `elements build -json` again, and the command prints `"ok": true`. ## What Most TypeScript Projects Run to Type Check In most TypeScript projects, your editor starts its own TypeScript server. Your agent runs `tsc`, `tsc` type checks every file, and your agent waits. Your bundler removes the type annotations and writes JavaScript. Your bundler does not type check your code. And your CI system runs `tsc` again. We designed Elements to have one program type check your code: the build server. ## A Type Error for the Browser Only We add a function to `greet.ts` that sorts a list of names: ```ts app/shared/greet.ts export function greet(name: string): string { return "Hello, " + name; } export let greeting = greet("Ada"); export function sortNames(names: string[]): string[] { return names.toSorted(); } ``` `sortNames` calls `toSorted`, and `toSorted` was added to JavaScript in ES2023. We save `greet.ts`. The build server type checks `greet.ts`, and `elements start` prints `State: Error` and a type error: ![The output of elements start in a terminal: State: Error, then one error at app/shared/greet.ts:8:16, Property 'toSorted' does not exist on type 'string\[\]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. The last line of the error says browser and TS2550.](/images/01a2354d-4423-7ab6-b4ed-adc8d1eed168/4b541941aaaa4340?w=1480&h=694#light) ![The output of elements start in a terminal: State: Error, then one error at app/shared/greet.ts:8:16, Property 'toSorted' does not exist on type 'string\[\]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later. The last line of the error says browser and TS2550.](/images/01a2354d-4462-72fd-b4ec-0e97df610c81/05d4ee877f14456c?w=1480&h=694#dark) The last line of that type error says `[browser]`. `greet.ts` runs on the server and in the browser, so the build server type checks `greet.ts` twice: once against the library types that the `lib` option lists for the server, and once against the library types that the `lib` option lists for the browser. The `toSorted` call has no type error for the server. The `toSorted` call is a type error for the browser only. ## TypeScript Options in config.jsoc An Elements project has no tsconfig. You set TypeScript options in `config.jsoc`. JSOC is our config language. JSOC has comments, identifier keys, an `env()` function and build tags. The `env()` function reads an environment variable. In a JSOC file, a build tag is written in a comment on the line above a key, such as the build tag `@browser` in the comment `/** @browser */`. When the same key is written twice, once with no build tag and once under `/** @browser */`, the build server reads the value with no build tag for the server and the value under `/** @browser */` for the browser. The demo app's `config.jsoc` has this `build` block: ```jsoc config.jsoc build: { typescript: { lib: ["es2023", "dom"], /** @browser */ lib: ["es2020", "dom"], }, }, ``` The `build` block sets `lib`, the list of library types, twice. The first `lib` line has no build tag, so the first `lib` line is the server's value, ES2023. The comment above the second `lib` line has the build tag `@browser`, so the second `lib` line is the browser's value, ES2020. The ES2023 library types declare `toSorted` on arrays, and the ES2020 library types do not. `elements build -json` prints the same `toSorted` type error, and the `targets` field of that type error has one value, `"browser"`: ```json "targets": [ "browser" ], ``` We delete `sortNames` from `greet.ts` and save. `elements start` prints `State: Ok`. ## Type Errors in Reactive HTML Files The build server also type checks the TypeScript in reactive HTML files. The demo app's home page is a reactive HTML file. The home page imports `greeting` from `greet.ts`: ```ehtml app/pages/home/template.ehtml import { greeting } from "#app/shared/greet"; ``` On line 124 of the home page, the expression `{greeting}` prints the value of `greeting`: ```ehtml app/pages/home/template.ehtml
{greeting}
``` We misspell `greeting` in that expression and save the home page: ```ehtml app/pages/home/template.ehtml{greting}
``` `elements start` prints `State: Error` and a type error that asks whether we meant `greeting`:   The type checker that checks TypeScript files found that type error in a reactive HTML file. The editor underlines `greting`, and `elements build -json` prints the same type error. We change `greting` back to `greeting` and save the home page. `elements start` prints `State: Ok`. ## Which Files Elements Type Checks After a Save The build server keeps the parsed source files and the resolved imports in memory. The parsed files and the resolved imports in memory are the source graph. After the first build of a project, the build server parses a file again only when the text of that file has changed. After you save a file, the build server type checks the file that you changed. If the changed file has a new export, or an export with a different type, the build server also type checks the files that import the changed file. If the exported types of one of those files changed too, the build server also type checks the files that import that file. For every file that the build server does not type check in a build, the build server keeps the type errors from the last build. Changing `"Ada"` to `42` added no export to `greet.ts` and changed the type of no export: `greeting` is still a `string`. So the build server type checked one file, `greet.ts`, once for the server and once for the browser. Adding `sortNames` added an export to `greet.ts`, so the build server also type checked the home page, which imports `greet.ts`. In the video, the build server's log shows the six most recent builds of the demo app taking 3 to 6 milliseconds each. ## A Type Error in the Editor While the Build Is Still Ok The build server builds the source graph from the files on disk, and builds one more source graph for each editor that connects to the build server. Each of these source graphs is a layer. Layer 0 is the source graph that the build server builds from the text of the files on disk. The editor's layer is copy on open: for each file that you have open in your editor, the editor's layer has a copy of that file, and the copy has the text that is in your editor, including text that you have not saved. For every other file, the editor's layer has the text that is on disk. We change `"Ada"` to `42` in `greet.ts` again and do not save. The build server type checks the unsaved text of `greet.ts` in the editor's layer and finds a type error: `42` is a number, and `greet` takes a string. The build server sends that type error to the editor, so the editor underlines `42`. The terminal that runs `elements start` still shows `State: Ok`, because `greet.ts` on disk has not changed. ## The Build Adds async and await to Your JavaScript When the build writes your JavaScript, the build needs to know which function each call is calling. The type checker has already worked that out during type checking, so the build does not work it out a second time. For example, the build adds `async` and `await` to the JavaScript of a function that calls `sql()`, the function in the `@elements/app` package that runs a SQL query. The demo app has a function, `listUsers`, that calls `sql()` with no `async` and no `await`: ```ts app/shared/services/users.ts import { sql } from "@elements/app"; export interface User { id: number; name: string; } export function listUsers(): User[] { return sql