Getting Started
Enable JS Runtime APIs in a Tsonic Project
New project
npx --yes tsonic@latest init --surface @tsonic/js
Existing project
npx --yes tsonic@latest add npm @tsonic/js
If you have tsonic installed globally, you can drop the npx --yes tsonic@latest prefix.
For a new project, init --surface @tsonic/js already installs and wires the
JS package. For an existing project, add npm @tsonic/js will:
- Install the
@tsonic/jsbindings package in your workspace (package.json) fortsctypechecking - Apply the package’s
.NETdependency manifest (tsonic.bindings.json) totsonic.workspace.json- Adds the required
dotnet.frameworkReferences/dotnet.packageReferences - Installs any additional
typespackages referenced by the manifest
- Adds the required
Then run npx --yes tsonic@latest restore (or npx --yes tsonic@latest build) to materialize .NET dependencies.
Minimal Example
export function main(): void {
const obj = JSON.parse<{ ok: boolean }>('{"ok": true}');
console.log(obj.ok);
}
Direct imports from @tsonic/js/index.js remain supported when you want explicit symbols.