Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

feat: Add muteNodeModules option #344

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
7 changes: 7 additions & 0 deletions src/checker/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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');
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface LoaderConfig {
silent?: boolean;
useCache?: boolean;
cacheDirectory?: string;
muteNodeModules?: boolean;
}

export interface OutputFile {
Expand Down