Skip to content

Commit b38cbcb

Browse files
authored
fix: invoke watcher in relevant .d.ts files (#597)
When webpack watches symlinked packages, it watches only for .js files. TypeScript, on the other hand, watches only for .d.ts files. To handle this case, we trigger a .d.ts watcher for every .js file. ✅ Closes: #593
1 parent 0b0703a commit b38cbcb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/typescript-reporter/reporter/ControlledTypeScriptSystem.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ function createControlledTypeScriptSystem(
8585

8686
function invokeFileWatchers(path: string, event: ts.FileWatcherEventKind) {
8787
const normalizedPath = realFileSystem.normalizePath(path);
88+
if (normalizedPath.endsWith('.js')) {
89+
// trigger relevant .d.ts file watcher - handles the case, when we have webpack watcher
90+
// that points to a symlinked package
91+
invokeFileWatchers(normalizedPath.slice(0, -3) + '.d.ts', event);
92+
}
8893

8994
const fileWatcherCallbacks = fileWatcherCallbacksMap.get(normalizedPath);
9095
if (fileWatcherCallbacks) {

0 commit comments

Comments
 (0)