TypeScript Compiler Options
types — TypeScript compiler option
Selects automatically included type packages. An empty array excludes automatic packages. Does not prevent imported modules from bringing their own types and creates no runtime globals. Default (5.8.3): all visible type packages when omitted. 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": { "types": [ "local" ] }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| types | type-package name array | Set in compilerOptions; default: all visible type packages when omitted. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [ "local" ], "noEmitOnError": true, "noEmit": true }, "files": [ "main.ts" ]}// File: main.tsconst checked: number = LOCAL_COUNT;// File: node_modules/@types/local/index.d.tsdeclare const LOCAL_COUNT: number;