Skip to content

Commit e3a30c0

Browse files
gasniergasnier
and
gasnier
authored
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fileName' of undefined (#1293)
* file can sometimes be undefined when using webpack devserver (with watch) * remove evil ! bypass... * comment is no more needed * Bump version to 9.1.2 - Fix removed files handling in watch mode Co-authored-by: gasnier <[email protected]>
1 parent f185321 commit e3a30c0

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v9.1.2
4+
5+
* [Fix removed files handling in watch mode](https://github.com/TypeStrong/ts-loader/pull/1293) - thanks @gasnier
6+
37
## v9.1.1
48

59
* [update CHANGELOG.md for 8.2.0 release](https://github.com/TypeStrong/ts-loader/pull/1291) - thanks @johnnyreilly

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-loader",
3-
"version": "9.1.1",
3+
"version": "9.1.2",
44
"description": "TypeScript loader for webpack",
55
"main": "index.js",
66
"types": "dist",
@@ -101,4 +101,4 @@
101101
"typescript": "*",
102102
"webpack": "*"
103103
}
104-
}
104+
}

src/after-compile.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ function determineFilesToCheckForErrors(
170170
).keys()) {
171171
const fileToCheckForErrors =
172172
files.get(fileName) || otherFiles.get(fileName);
173-
addFileToCheckForErrors(fileName, fileToCheckForErrors!);
173+
if (fileToCheckForErrors) {//file may have been removed
174+
addFileToCheckForErrors(fileName, fileToCheckForErrors);
175+
}
174176
}
175177
}
176178
}
@@ -184,7 +186,7 @@ function determineFilesToCheckForErrors(
184186
return filesToCheckForErrors;
185187

186188
function addFileToCheckForErrors(filePath: FilePathKey, file: TSFile) {
187-
if (!isReferencedFile(instance, filePath)) {
189+
if (file && !isReferencedFile(instance, filePath)) {
188190
filesToCheckForErrors.set(filePath, file);
189191
}
190192
}

0 commit comments

Comments
 (0)