From eb2619c7dd802fcf104d350b95720f116a08906b Mon Sep 17 00:00:00 2001 From: Tim Suchanek Date: Mon, 9 Jan 2017 12:44:19 +0100 Subject: [PATCH] feat: Add muteNodeModules option --- README.md | 4 ++++ src/checker/runtime.ts | 7 +++++++ src/interfaces.ts | 1 + 3 files changed, 12 insertions(+) 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 {