@syncrona/typescript-plugin
v1.0.0
Published
SyncroNow AI build plugin that type-checks and transpiles .ts files with the TypeScript compiler (honors tsconfig.json).
Readme
@syncrona/typescript-plugin
| |
|
|
|
|
|:--:|:--:|:--:|:--:|:--:|
Overview
SyncroNow AI is the ServiceNow scoped-application toolchain behind the syncrona CLI. This package is one of its build plugins: register it in the rules array of your sync.config.js and syncrona build runs it over every matching file.
This plugin allows you to run the TypeScript compiler on .ts files. Supports tsconfig.json files.
Installation
npm i -D @syncrona/typescript-pluginOptions
| Key | Type | Default | Description |
| ----------------- | ---------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| transpile | boolean | true | Whether or not the contents of the typescript file should be transpiled. Useful if you want to use Babel to transpile instead but still want type checking |
| compilerOptions | typescript.CompilerOptions | null | Same as compilerOptions in a tsconfig.json file |
Order of Configurations
Later entries win on every overlapping key:
tsconfig.json— the nearest one found by walking up from the file being compiled, with itsextendschain resolved. This is the base.compilerOptionsfromsync.config.js— merged on top, so a value set here overrides the same key intsconfig.json. Both the string spelling (target: "ES2021") and an already-resolvedtypescript.ScriptTargetvalue are accepted; an unparsable value fails the push instead of being ignored.- The plugin's own defaults, applied only where neither source set the key:
target→ES2021, the ECMAScript level current ServiceNow releases support. Pinned deliberately, because TypeScript's own default tracks the newest language level and changes between compiler majors.module→ follows the effectivetarget(ES2015for an ES2015+ target,CommonJSbelow it), which is what TypeScript 5 did before its default moved.moduleResolution→Bundler, but only where TypeScript would otherwise default toClassic, which cannot seenode_modulesat all. Atsconfig.jsonthat already implies a node-aware resolution is left alone.alwaysStrict→falsefor the emit when neitherstrictnoralwaysStrictwas configured anywhere, so the transpiled output carries no"use strict"prologue. ServiceNow scripts lean on implicit globals, which strict mode turns into runtime errors.
The same effective option set drives the type check and the emit, so a knob that
relaxes checking (noImplicitAny, skipLibCheck, strict) really does unblock a
push.
Example Usage
This example takes .ts files and only type checks them.
// sync.config.js
module.exports = {
rules: [
{
match: /\.ts$/,
plugins: [
{
name: "@syncrona/typescript-plugin",
options: {
transpile: false,
},
},
],
},
],
};