Skip to content

Commit

Permalink
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fi…
Browse files Browse the repository at this point in the history
…leName' 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 <gasnier@cervval.com>
  • Loading branch information
gasnier and gasnier committed May 5, 2021
1 parent f185321 commit e3a30c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog

## v9.1.2

* [Fix removed files handling in watch mode](https://github.com/TypeStrong/ts-loader/pull/1293) - thanks @gasnier

## v9.1.1

* [update CHANGELOG.md for 8.2.0 release](https://github.com/TypeStrong/ts-loader/pull/1291) - thanks @johnnyreilly
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "ts-loader",
"version": "9.1.1",
"version": "9.1.2",
"description": "TypeScript loader for webpack",
"main": "index.js",
"types": "dist",
Expand Down Expand Up @@ -101,4 +101,4 @@
"typescript": "*",
"webpack": "*"
}
}
}
6 changes: 4 additions & 2 deletions src/after-compile.ts
Expand Up @@ -170,7 +170,9 @@ function determineFilesToCheckForErrors(
).keys()) {
const fileToCheckForErrors =
files.get(fileName) || otherFiles.get(fileName);
addFileToCheckForErrors(fileName, fileToCheckForErrors!);
if (fileToCheckForErrors) {//file may have been removed
addFileToCheckForErrors(fileName, fileToCheckForErrors);
}
}
}
}
Expand All @@ -184,7 +186,7 @@ function determineFilesToCheckForErrors(
return filesToCheckForErrors;

function addFileToCheckForErrors(filePath: FilePathKey, file: TSFile) {
if (!isReferencedFile(instance, filePath)) {
if (file && !isReferencedFile(instance, filePath)) {
filesToCheckForErrors.set(filePath, file);
}
}
Expand Down

0 comments on commit e3a30c0

Please sign in to comment.