Skip to content

Commit

Permalink
Report errors in JS(X) files when CheckJS is enabled (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmuli authored and johnnyreilly committed Jun 25, 2017
1 parent efe487f commit bcbb3ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/after-compile.ts
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Expand Up @@ -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;

0 comments on commit bcbb3ce

Please sign in to comment.