diff --git a/README.md b/README.md index 4e9e874..853df82 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,10 @@ Use pre-compiled files if any. Files must be named as `{filename}.js` and `{file Directory when cache is stored. +### muteNodeModules *(boolean) (default=false)* + +Mute TypeScript Errors that occur in libraries in the node_modules folder. + ## Compiler options You can pass compiler options inside loader query string or in tsconfig file. diff --git a/src/checker/runtime.ts b/src/checker/runtime.ts index cfc2f58..953f97d 100644 --- a/src/checker/runtime.ts +++ b/src/checker/runtime.ts @@ -344,6 +344,7 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re function processDiagnostics({seq}: Diagnostics.Request) { let silent = !!loaderConfig.silent; + const muteNodeModules = !!loaderConfig.muteNodeModules; const timeStart = +new Date(); @@ -369,6 +370,12 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re } const processedDiagnostics = allDiagnostics + .filter(diag => { + if (muteNodeModules && diag.file) { + return !/node_modules/.test(diag.file.fileName) + } + return true + }) .filter(diag => !ignoreDiagnostics[diag.code]) .map(diagnostic => { const message = compiler.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); diff --git a/src/interfaces.ts b/src/interfaces.ts index 97bc473..bcc92d5 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -20,6 +20,7 @@ export interface LoaderConfig { silent?: boolean; useCache?: boolean; cacheDirectory?: string; + muteNodeModules?: boolean; } export interface OutputFile {