TypeScript Compiler Options
moduleSuffixes — TypeScript compiler option
Customizes suffix candidates in file lookup. Put preferred platform suffixes before the empty string to retain ordinary lookup. Does not rename runtime files. Default (5.8.3): ordinary unsuffixed lookup. Create the labeled files in an isolated local project and run tsc -p tsconfig.json. Expected: no diagnostics; emitted files: none. Local multi-file fixture, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "moduleSuffixes": [ ".native", "" ] }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| moduleSuffixes | string array | Set in compilerOptions; default: ordinary unsuffixed lookup. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "noEmit": true, "moduleSuffixes": [ ".native", "" ] }, "files": [ "main.ts" ]}// File: main.tsimport { mode } from "./platform"; const checked: "native" = mode;// File: platform.native.tsexport const mode = "native" as const;// File: platform.tsexport const mode = "generic" as const;