From e3a30c090a90ffc4f2bb21ed1d08ea98f361ac25 Mon Sep 17 00:00:00 2001 From: gasnier Date: Wed, 5 May 2021 22:16:57 +0200 Subject: [PATCH] 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 --- CHANGELOG.md | 4 ++++ package.json | 4 ++-- src/after-compile.ts | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc9619197..97c09f42b 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/package.json b/package.json index 2c9cbb3ca..22c612375 100644 --- a/package.json +++ b/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", @@ -101,4 +101,4 @@ "typescript": "*", "webpack": "*" } -} +} \ No newline at end of file diff --git a/src/after-compile.ts b/src/after-compile.ts index c6e6a887c..99cb9f37b 100644 --- a/src/after-compile.ts +++ b/src/after-compile.ts @@ -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); + } } } } @@ -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); } }