Skip to content

tsoniclang/js

Repository files navigation

@tsonic/js

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.

Prerequisites

Quick Start (surface-first, no @tsonic/js imports required)

mkdir my-app && cd my-app
npx --yes tsonic@latest init --surface @tsonic/js
export function main(): void {
  const value = JSON.parse<{ x: number }>('{"x": 1}');
  console.log(JSON.stringify(value));
}

Build/run:

npm run dev

Existing project

npx --yes tsonic@latest add npm @tsonic/js

If the workspace is not already JS surface, set surface in tsonic.workspace.json to @tsonic/js:

{
  "surface": "@tsonic/js"
}

Optional direct imports

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";

Core APIs

  • console
  • JSON
  • Map, Set, WeakMap, WeakSet
  • Date, Math, RegExp, Number, String
  • Timers
  • globals like parseInt, parseFloat, encodeURI

Relationship to @tsonic/nodejs

  • @tsonic/js = JS runtime surface
  • @tsonic/nodejs = Node-style modules (node:fs, node:path, node:crypto, ...)

Versioning

  • 10versions/10/ → npm: @tsonic/js@10.x

Publish:

npm publish versions/10 --access public

Development

Run the package validation suite with progress output:

npm run selftest

The 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.

License

MIT

About

d.ts files for the js runtime

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors