Skip to content

Commit 25f8ef3

Browse files
committed
Merge pull request microsoft#7711 from YuichiNukiyama/fix4957
Throw error when tsconfig.json has excludes without exclude property
2 parents 01663a1 + e461d12 commit 25f8ef3

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/compiler/commandLineParser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ namespace ts {
667667
}
668668
}
669669
}
670+
if (hasProperty(json, "excludes") && !hasProperty(json, "exclude")) {
671+
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
672+
}
670673
return fileNames;
671674
}
672675
}

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,6 +2620,10 @@
26202620
"category": "Message",
26212621
"code": 6113
26222622
},
2623+
"Unknown option 'excludes'. Did you mean 'exclude'?": {
2624+
"category": "Error",
2625+
"code": 6114
2626+
},
26232627

26242628
"Variable '{0}' implicitly has an '{1}' type.": {
26252629
"category": "Error",

tests/cases/unittests/tsconfigParsing.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ namespace ts {
1313
assert.isTrue(undefined === parsed.config);
1414
assert.isTrue(undefined !== parsed.error);
1515
}
16+
17+
function assertParseErrorWithExcludesKeyword(jsonText: string) {
18+
let parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText);
19+
let parsedCommand = ts.parseJsonConfigFileContent(parsed, ts.sys, "tests/cases/unittests");
20+
assert.isTrue(undefined !== parsedCommand.errors);
21+
}
1622

1723
it("returns empty config for file with only whitespaces", () => {
1824
assertParseResult("", { config : {} });
@@ -102,5 +108,17 @@ namespace ts {
102108
config: { compilerOptions: { lib: "es5,es6" } }
103109
});
104110
});
111+
112+
it("returns error when tsconfig have excludes", () => {
113+
assertParseErrorWithExcludesKeyword(
114+
`{
115+
"compilerOptions": {
116+
"lib": "es5"
117+
},
118+
"excludes": [
119+
"foge.ts"
120+
]
121+
}`);
122+
});
105123
});
106124
}

0 commit comments

Comments
 (0)