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

Commit 519c554

Browse files
committed
feat(*): add option to disable .d.ts files typechecks
1 parent dc66680 commit 519c554

File tree

6 files changed

+23
-35
lines changed

6 files changed

+23
-35
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"ps-node": "0.0.5",
6666
"rimraf": "^2.5.0",
6767
"tslint": "3.5.0-dev.1",
68-
"typescript": "^1.9.0-dev.20160330",
68+
"typescript": "^1.9.0-dev.20160415",
6969
"webpack": "2.1.0-beta.4"
7070
}
7171
}

src/checker-runtime.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ function processInit(payload: IInitPayload) {
195195
});
196196
}
197197

198+
let DECLARATION_FILE = /\.d\.ts/;
199+
198200
function processCompile(payload: ICompilePayload) {
199201
let instanceName = env.options.instanceName || 'default';
200202
let silent = !!env.options.forkCheckerSilent;
@@ -213,7 +215,21 @@ function processCompile(payload: ICompilePayload) {
213215
env.files = payload.files;
214216
env.resolutionCache = payload.resolutionCache;
215217
let program = env.program = env.service.getProgram();
216-
let allDiagnostics = env.compiler.getPreEmitDiagnostics(program);
218+
219+
let allDiagnostics: ts.Diagnostic[] = [];
220+
if (env.options.skipDeclarationFilesCheck) {
221+
let sourceFiles = program.getSourceFiles();
222+
sourceFiles.forEach(sourceFile => {
223+
if (!sourceFile.fileName.match(DECLARATION_FILE)) {
224+
allDiagnostics = allDiagnostics.concat(env.compiler.getPreEmitDiagnostics(program, sourceFile));
225+
}
226+
});
227+
// FIXME internal API
228+
allDiagnostics = (env.compiler as any).sortAndDeduplicateDiagnostics(allDiagnostics);
229+
} else {
230+
allDiagnostics = env.compiler.getPreEmitDiagnostics(program);
231+
}
232+
217233
if (allDiagnostics.length) {
218234
allDiagnostics.forEach(diagnostic => {
219235
let message = env.compiler.flattenDiagnosticMessageText(diagnostic.messageText, '\n');

src/host.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export interface ICompilerOptions extends ts.CompilerOptions {
4646
useBabel?: boolean;
4747
babelOptions?: any;
4848
usePrecompiledFiles?: boolean;
49+
skipDeclarationFilesCheck?: boolean;
4950
useCache?: boolean;
5051
cacheDirectory?: string;
5152
files?: any;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,4 @@ class ForkCheckerPlugin {
215215

216216
(loader as any).ForkCheckerPlugin = ForkCheckerPlugin;
217217

218-
export = loader;
218+
module.exports = loader;

src/instance.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export function ensureInstance(webpack: IWebPack, options: ICompilerOptions, ins
188188
sourceMap: true,
189189
verbose: false,
190190
noLib: false,
191+
skipDefaultLibCheck: true,
191192
suppressOutputPathCheck: true,
192193
sourceRoot: process.cwd()
193194
});

src/tsconfig.json

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,16 @@
11
{
2-
"version": "1.5.0-beta",
32
"compilerOptions": {
43
"target": "es6",
54
"declaration": false,
5+
"moduleResolution": "node",
66
"noImplicitAny": false,
77
"removeComments": true,
88
"noLib": false,
99
"preserveConstEnums": true,
1010
"suppressImplicitAnyIndexErrors": true
1111
},
1212
"compileOnSave": false,
13-
"filesGlob": [
14-
"./**/*.ts",
15-
"!./node_modules/**/*.ts"
16-
],
17-
"files": [
18-
"./cache.ts",
19-
"./checker-runtime.ts",
20-
"./checker.ts",
21-
"./defines.d.ts",
22-
"./deps.ts",
23-
"./helpers.ts",
24-
"./host.ts",
25-
"./index.ts",
26-
"./instance.ts",
27-
"./resolver.ts",
28-
"./test/babel.ts",
29-
"./test/checker.ts",
30-
"./test/declaration.ts",
31-
"./test/fixtures/babel/babel.ts",
32-
"./test/fixtures/basic/basic.ts",
33-
"./test/fixtures/checker/to-check.ts",
34-
"./test/fixtures/declaration/basic.ts",
35-
"./test/fixtures/declaration/iface.ts",
36-
"./test/fixtures/errors/with-type-errors.ts",
37-
"./test/fixtures/salsa/index.ts",
38-
"./test/index.ts",
39-
"./test/salsa.ts",
40-
"./test/utils.ts",
41-
"./tsconfig-utils.ts"
42-
],
4313
"atom": {
44-
"rewriteTsconfig": true
14+
"rewriteTsconfig": false
4515
}
4616
}

0 commit comments

Comments
 (0)