TypeScript Compiler Options

watchFile — TypeScript watch configuration

Selects the strategy for watching individual files. Valid choices include fixedPollingInterval, priorityPollingInterval, dynamicPriorityPolling, fixedChunkSizePolling, useFsEvents and useFsEventsOnParentDirectory. Polling periodically inspects file state; event-based watching depends on the operating system. The example verifies an edit under fixed polling, not comparative CPU usage. Baseline: TypeScript 5.8.3. Default: useFsEvents (CLI metadata). Create the labeled files in an isolated project; omit file labels. Stop the ongoing watcher with Ctrl+C.

Formal Syntax & Structure

typescript syntaxtypescript
{  "watchOptions": {    "watchFile": "fixedPollingInterval"  }}

Parameters & Attributes

NameTypeDescription
watchFilestring enumWatch option; default: useFsEvents (CLI metadata).

Working Example

Example Snippettypescript
// File: tsconfig.json (omit this label){  "compilerOptions": {    "target": "ES2022",    "module": "CommonJS",    "strict": true,    "types": [],    "noEmit": true,    "preserveWatchOutput": true  },  "include": [    "src/**/*.ts"  ],  "watchOptions": {    "watchFile": "fixedPollingInterval"  }}// File: src/index.ts (omit this label)export const count: number = 1;
// Run in a temporary project:// tsc -p . --watch --pretty false// After initial compilation, apply the following file change; stop watch with Ctrl+C.// Replace or create: src/index.tsexport const count: number = "bad";
TypeScript Reference