Watch Options
You can configure the how TypeScript --watch works. This section is mainly for handling case where fs.watch and fs.watchFile have additional constraints like on Linux. You can read more at Configuring Watch.
watchFile
Allowed:
fixedpollinginterval,prioritypollinginterval,dynamicprioritypolling,fixedchunksizepolling,usefsevents,usefseventsonparentdirectoryReleased: 3.8
The strategy for how individual files are watched.
fixedPollingInterval: Check every file for changes several times a second at a fixed interval.priorityPollingInterval: Check every file for changes several times a second, but use heuristics to check certain types of files less frequently than others.dynamicPriorityPolling: Use a dynamic queue where less-frequently modified files will be checked less often.useFsEvents(the default): Attempt to use the operating system/file system's native events for file changes.useFsEventsOnParentDirectory: Attempt to use the operating system/file system's native events to listen for changes on a file's parent directory
watchDirectory
Allowed:
usefsevents,fixedpollinginterval,dynamicprioritypolling,fixedchunksizepollingReleased: 3.8
The strategy for how entire directory trees are watched under systems that lack recursive file-watching functionality.
fixedPollingInterval: Check every directory for changes several times a second at a fixed interval.dynamicPriorityPolling: Use a dynamic queue where less-frequently modified directories will be checked less often.useFsEvents(the default): Attempt to use the operating system/file system's native events for directory changes.
fallbackPolling
Allowed:
fixedinterval,priorityinterval,dynamicpriority,fixedchunksizeReleased: 3.8
When using file system events, this option specifies the polling strategy that gets used when the system runs out of native file watchers and/or doesn't support native file watchers.
fixedPollingInterval: Check every file for changes several times a second at a fixed interval.priorityPollingInterval: Check every file for changes several times a second, but use heuristics to check certain types of files less frequently than others.dynamicPriorityPolling: Use a dynamic queue where less-frequently modified files will be checked less often.synchronousWatchDirectory: Disable deferred watching on directories. Deferred watching is useful when lots of file changes might occur at once (e.g. a change innode_modulesfrom runningnpm install), but you might want to disable it with this flag for some less-common setups.
synchronousWatchDirectory
- Released: 3.8
Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively. Instead of giving a small timeout to allow for potentially multiple edits to occur on a file.
{
"watchOptions": {
"synchronousWatchDirectory": true
}
}excludeDirectories
- Released: 4.2
You can use excludeFiles to drastically reduce the number of files which are watched during --watch. This can be a useful way to reduce the number of open file which TypeScript tracks on Linux.
{
"watchOptions": {
"excludeDirectories": ["**/node_modules", "_build", "temp/*"]
}
}excludeFiles
- Released: 4.2
You can use excludeFiles to remove a set of specific files from the files which are watched.
{
"watchOptions": {
"excludeFiles": ["temp/file.ts"]
}
}