Skip to content

Commit bcbb3ce

Browse files
schmulijohnnyreilly
authored andcommitted
Report errors in JS(X) files when CheckJS is enabled (#564)
1 parent efe487f commit bcbb3ce

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/after-compile.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,12 @@ function provideErrorsToWebpack(
124124
modules: Modules,
125125
instance: interfaces.TSInstance
126126
) {
127-
const { compiler, languageService, files, loaderOptions } = instance;
127+
const { compiler, languageService, files, loaderOptions, compilerOptions } = instance;
128+
129+
let filePathRegex = !!compilerOptions.checkJs ? constants.dtsTsTsxJsJsxRegex : constants.dtsTsTsxRegex;
130+
128131
Object.keys(filesToCheckForErrors)
129-
.filter(filePath => !!filePath.match(constants.dtsTsTsxRegex))
132+
.filter(filePath => !!filePath.match(filePathRegex))
130133
.forEach(filePath => {
131134
const errors = languageService.getSyntacticDiagnostics(filePath).concat(languageService.getSemanticDiagnostics(filePath));
132135
if (errors.length > 0) {

src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const ModuleKindCommonJs = 1;
1515
export const tsTsxRegex = /\.ts(x?)$/i;
1616
export const dtsDtsxRegex = /\.d\.ts(x?)$/i;
1717
export const dtsTsTsxRegex = /(\.d)?\.ts(x?)$/i;
18+
export const dtsTsTsxJsJsxRegex = /((\.d)?\.ts(x?)|js(x?))$/i;
1819
export const tsTsxJsJsxRegex = /\.tsx?$|\.jsx?$/i;
1920
export const jsJsx = /\.js(x?)$/i;
2021
export const jsJsxMap = /\.js(x?)\.map$/i;

0 commit comments

Comments
 (0)