Skip to content

tabscript

tabscript(inData, options?): object

Defined in: .work/repos/tabscript/src/tabscript.ts:71

Transpiles TabScript to TypeScript or JavaScript.

string

The input TabScript.

Options = {}

An optional object containing the following optional properties:

  • debug When true, each consumed token is logged. If it’s a function, that function will be called instead of console.debug.
  • recover When true, the function will attempt to continue transpilation when it encounters an error in the input (or unsupported syntax), instead of throwing. Errors are logged to console.error.
  • ‘js’ When true, we’ll transpile to JavaScript instead of TypeScript. Note that TabScript will not perform any type checking, just strip out the type info.
  • transformImport An async function that gets an import URI, and returns the URI to be include included in the transpiled output.
  • whitespace When "preserve" (the default), output is made to closely align with input line/column positions. When "pretty", output is formatted with human-friendly indentation and spacing.
  • loadPlugin Function to load plugin modules from a path.

object

An object containing:

  • code: The transpiled TypeScript/JavaScript code.
  • errors: An array of errors encountered during transpilation (if any) of the form: { message: string, line: number, column: number, offset: number }. If recover is not set, this array will contain at most one error.
  • map: An object mapping input offsets to output offsets, of the form: { in: number[], out: number[] }, where each index corresponds to a mapping pair.

code: string

errors: ParseError[]

map: object

in: number[]

out: number[]

ParserError, if there’s a compilation error and recover is not set.