KC's Workspace
    Preparing search index...

    Options for transforming a JavaScript or TypeScript file.

    Options are listed in evaluation order: the source is parsed (lang, sourceType), declarations are emitted (typescript.declaration), then transforms run (typescript, decorator, plugins, jsx, target), followed by the inject and define plugins, and finally codegen (sourcemap). helpers configures the runtime helpers the transforms emit.

    transform

    interface TransformOptions {
        assumptions?: CompilerAssumptions;
        cwd?: string;
        decorator?: DecoratorOptions;
        define?: Record<string, string>;
        helpers?: Helpers;
        inject?: Record<string, string | [string, string]>;
        jsx?: "preserve" | JsxOptions;
        lang?: "jsx" | "js" | "ts" | "tsx" | "dts";
        plugins?: PluginsOptions;
        sourcemap?: boolean;
        sourceType?: "script" | "module" | "commonjs" | "unambiguous";
        target?: string | string[];
        typescript?: TypeScriptOptions;
    }
    Index
    assumptions?: CompilerAssumptions

    Set assumptions in order to produce smaller output.

    cwd?: string

    The current working directory. Used to resolve relative paths in other options.

    decorator?: DecoratorOptions

    Decorator plugin

    define?: Record<string, string>

    Define Plugin

    Runs after the inject plugin.

    helpers?: Helpers

    Behaviour for runtime helpers.

    inject?: Record<string, string | [string, string]>

    Inject Plugin

    Runs after all transforms.

    jsx?: "preserve" | JsxOptions

    Configure how TSX and JSX are transformed.

    lang?: "jsx" | "js" | "ts" | "tsx" | "dts"

    Treat the source text as js, jsx, ts, tsx, or dts.

    plugins?: PluginsOptions

    Third-party plugins to use.

    sourcemap?: boolean

    Enable source map generation.

    When true, the sourceMap field of transform result objects will be populated.

    false
    
    sourceType?: "script" | "module" | "commonjs" | "unambiguous"

    Treat the source text as script or module code.

    target?: string | string[]

    Sets the target environment for the generated JavaScript.

    The lowest target is es2015.

    Example:

    • 'es2015'
    • ['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']
    typescript?: TypeScriptOptions

    Configure how TypeScript is transformed.

    typescript.declaration is evaluated before all transforms.