JavaScript runtime bindings for Tsonic.
This package is part of Tsonic: https://tsonic.org.
@tsonic/js provides JS runtime APIs (JSON, console, Map, Set, Date, timers, etc.) for Tsonic projects.
- Install the .NET 10 SDK: https://dotnet.microsoft.com/download
- Verify:
dotnet --version
mkdir my-app && cd my-app
npx --yes tsonic@latest init --surface @tsonic/jsexport function main(): void {
const value = JSON.parse<{ x: number }>('{"x": 1}');
console.log(JSON.stringify(value));
}Build/run:
npm run devnpx --yes tsonic@latest add npm @tsonic/jsIf the workspace is not already JS surface, set surface in
tsonic.workspace.json to @tsonic/js:
{
"surface": "@tsonic/js"
}Surface mode enables natural JS authoring, but explicit subpath imports remain supported:
import { Date } from "@tsonic/js/index.js";
import { Math } from "@tsonic/js/index.js";consoleJSONMap,Set,WeakMap,WeakSetDate,Math,RegExp,Number,StringTimers- globals like
parseInt,parseFloat,encodeURI
@tsonic/js= JS runtime surface@tsonic/nodejs= Node-style modules (node:fs,node:path,node:crypto, ...)
10→versions/10/→ npm:@tsonic/js@10.x
Publish:
npm publish versions/10 --access publicRun the package validation suite with progress output:
npm run selftestThe selftest builds the package fixture and runs the JS API matrix for arrays, typed arrays, JSON, maps, sets, weak collections, numbers, strings, dates, timers, errors, console, globals, and regular expressions.
MIT