Allow hooks for watch events #33388
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Search Terms
Suggestion
Allow a ts file to react to actions performed by tsc while it is running in
--watch
mode. This can be done by having that file export specific members of specific known types that tsc will execute at the appropriate time.Use Cases
I would like to automatically regenerate an index.ts file before letting tsc proceed with its normal compilation that would include the now altered index.ts.
In one of my projects, I would also want to restart a server after compilation. Others may want to do other build related tasks, such as re-running a subset of tests after build for example.
Examples
Given a command line
tsc --build --watch --watchHook ./watcher.ts
and the following watcher.ts file:
I would like tsc to behave as described in the watcher.ts file. As with most TS settings, there should be an analog in the tsconfig.json file, where the path to the hooks file is relative to the tsconfig.json file.
Currently, in order to do these sorts of things, one has to use a separate builder like gulp, which is somewhat complex to use for projects that use project references.
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: