From 17b5be1342662d918d496a06d32ab15224b8f475 Mon Sep 17 00:00:00 2001 From: Schmulik Raskin Date: Sun, 25 Jun 2017 13:30:42 +0300 Subject: [PATCH] Report errors in JS(X) files when CheckJS is enabled --- src/after-compile.ts | 7 +++++-- src/constants.ts | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/after-compile.ts b/src/after-compile.ts index 97db8dd39..3dace35d6 100644 --- a/src/after-compile.ts +++ b/src/after-compile.ts @@ -124,9 +124,12 @@ function provideErrorsToWebpack( modules: Modules, instance: interfaces.TSInstance ) { - const { compiler, languageService, files, loaderOptions } = instance; + const { compiler, languageService, files, loaderOptions, compilerOptions } = instance; + + let filePathRegex = !!compilerOptions.checkJs ? constants.dtsTsTsxJsJsxRegex : constants.dtsTsTsxRegex; + Object.keys(filesToCheckForErrors) - .filter(filePath => !!filePath.match(constants.dtsTsTsxRegex)) + .filter(filePath => !!filePath.match(filePathRegex)) .forEach(filePath => { const errors = languageService.getSyntacticDiagnostics(filePath).concat(languageService.getSemanticDiagnostics(filePath)); if (errors.length > 0) { diff --git a/src/constants.ts b/src/constants.ts index 0c35e89a9..79018d6ec 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -15,6 +15,7 @@ export const ModuleKindCommonJs = 1; export const tsTsxRegex = /\.ts(x?)$/i; export const dtsDtsxRegex = /\.d\.ts(x?)$/i; export const dtsTsTsxRegex = /(\.d)?\.ts(x?)$/i; +export const dtsTsTsxJsJsxRegex = /((\.d)?\.ts(x?)|js(x?))$/i; export const tsTsxJsJsxRegex = /\.tsx?$|\.jsx?$/i; export const jsJsx = /\.js(x?)$/i; export const jsJsxMap = /\.js(x?)\.map$/i; \ No newline at end of file