Edit source

tsonic.json reference

The project file is a strict JSON object. Unknown fields are rejected. It is not a tsconfig.json, and fields such as compilerOptions, baseUrl, paths, tsconfig, extends, and references are deliberately unsupported.

Project fields

FieldRequiredTypeDefaultContract
$schemaNostringnoneEditor metadata; accepted but not semantic input
entryPointYesnonempty stringnoneFinal .ts or .mts source below rootDir; declaration files are rejected
rootFilesNononempty distinct string array[entryPoint]Additional final .ts/.mts roots; must include entryPoint after resolution
rootDirNononempty stringproject-file directoryRoot for source resolution
outDirNononempty stringdist/tsonicCompiler-owned publication root
cacheDirNononempty string.tsonic/cacheDisposable compiler and target-tool cache; must not overlap outDir
targetsYesnonempty target arraynoneOne entry per unique target id

Every resolved root file must remain strictly inside the resolved project root. cacheDir is resolved from the project-file directory. Tsonic and target packs write cache data beneath it instead of modifying installed packages. It must be disjoint from outDir so atomic publication never includes or deletes cache state.

Target fields

FieldRequiredTypeContract
idYesstringLowercase ASCII id with single hyphen-separated segments
surfacesNodistinct string arrayExplicit source-surface ids; an empty array is valid
optionsNoobjectValidated strictly by the selected target pack

packages is not a target field. Install a capability package through npm instead.

Complete example

{
  "entryPoint": "index.ts",
  "rootFiles": ["index.ts", "startup.ts"],
  "rootDir": "src",
  "outDir": "out",
  "targets": [
    {
      "id": "csharp",
      "surfaces": ["js"],
      "options": {
        "namespace": "Example.Generated",
        "outputType": "Exe"
      }
    },
    {
      "id": "rust",
      "surfaces": ["js"],
      "options": {
        "crateName": "example_generated",
        "outputType": "bin"
      }
    }
  ]
}

$schema is accepted so editors can associate a schema chosen by the user or workspace. Tsonic does not currently publish a canonical schema URL, so the example deliberately omits one.

See the exact C# options and Rust options.