KC's Workspace
    Preparing search index...
    interface TypeScriptOptions {
        allowDeclareFields?: boolean;
        allowNamespaces?: boolean;
        declaration?: IsolatedDeclarationsOptions;
        jsxPragma?: string;
        jsxPragmaFrag?: string;
        onlyRemoveTypeImports?: boolean;
        removeClassFieldsWithoutInitializer?: boolean;
        rewriteImportExtensions?: boolean | "remove" | "rewrite";
    }
    Index

    Properties

    allowDeclareFields?: boolean

    When enabled, type-only class fields are only removed if they are prefixed with the declare modifier:

    Allowing declare fields is built-in support in Oxc without any option. If you want to remove class fields without initializer, you can use remove_class_fields_without_initializer: true instead.

    allowNamespaces?: boolean

    Also generate a .d.ts declaration file for TypeScript files.

    The source file must be compliant with all isolatedDeclarations requirements.

    false
    
    jsxPragma?: string
    jsxPragmaFrag?: string
    onlyRemoveTypeImports?: boolean
    removeClassFieldsWithoutInitializer?: boolean

    When enabled, class fields without initializers are removed.

    For example:

    class Foo {
    x: number;
    y: number = 0;
    }

    // transform into

    class Foo {
    x: number;
    }

    The option is used to align with the behavior of TypeScript's useDefineForClassFields: false option. When you want to enable this, you also need to set [crate::CompilerAssumptions::set_public_class_fields] to true. The set_public_class_fields: true + remove_class_fields_without_initializer: true is equivalent to useDefineForClassFields: false in TypeScript.

    When set_public_class_fields is true and class-properties plugin is enabled, the above example transforms into:

    class Foo {
    constructor() {
    this.y = 0;
    }
    }

    Defaults to false.

    rewriteImportExtensions?: boolean | "remove" | "rewrite"

    Rewrite or remove TypeScript import/export declaration extensions.

    • When set to rewrite, it will change .ts, .mts, .cts extensions to .js, .mjs, .cjs respectively.
    • When set to remove, it will remove .ts/.mts/.cts/.tsx extension entirely.
    • When set to true, it's equivalent to rewrite.
    • When set to false or omitted, no changes will be made to the extensions.
    false