Native modules | TypeScript | Program targets

Targets · TypeScript · Native modules

The hand-written, per-platform code behind NATIVE functions.

How a Program becomes TypeScript, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

Most of a program is written in Program and rendered to TypeScript. A NATIVE function is the exception: its body is hand-written. Because JavaScript is valid TypeScript, a native with no ts NATIVE row reuses its js body verbatim, wrapped in a typed signature; a ts row is added only when the body needs types the plain JavaScript cannot express.

Each native module's top-level functions and classes are gathered into a registry so generated code can reach them by name, with their .d.ts declarations honoured by the compiler.

The drivers are native code — Ui.Dom.Driver , Animate.Frame.Driver , Network.Web.Driver — the one place the real platform ( document , fetch , requestAnimationFrame ) is touched. Reactive and Context are themselves native modules, bundled first, so the result is one typed artifact — runtime, native bodies, and program — that a page or Node can load.

Recommended articles