Skip to content

Commit bf6f060

Browse files
committed
Define interface for TSConfig. Change compilerOnSave to compileOnSave
1 parent dbabc12 commit bf6f060

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

src/compiler/commandLineParser.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,14 +1739,24 @@ namespace ts {
17391739
return false;
17401740
}
17411741

1742+
/** @internal */
1743+
export interface TSConfig {
1744+
compilerOptions: CompilerOptions;
1745+
compileOnSave: boolean | undefined;
1746+
exclude?: ReadonlyArray<string>;
1747+
files: ReadonlyArray<string> | undefined;
1748+
include?: ReadonlyArray<string>;
1749+
references: ReadonlyArray<ProjectReference> | undefined;
1750+
}
1751+
17421752
/**
17431753
* Generate an uncommented, complete tsconfig for use with "--showConfig"
17441754
* @param configParseResult options to be generated into tsconfig.json
17451755
* @param configFileName name of the parsed config file - output paths will be generated relative to this
17461756
* @param host provides current directory and case sensitivity services
17471757
*/
17481758
/** @internal */
1749-
export function convertToTSConfig(configParseResult: ParsedCommandLine, configFileName: string, host: { getCurrentDirectory(): string, useCaseSensitiveFileNames: boolean }): object {
1759+
export function convertToTSConfig(configParseResult: ParsedCommandLine, configFileName: string, host: { getCurrentDirectory(): string, useCaseSensitiveFileNames: boolean }): TSConfig {
17501760
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
17511761
const files = map(
17521762
filter(
@@ -1774,13 +1784,13 @@ namespace ts {
17741784
build: undefined,
17751785
version: undefined,
17761786
},
1777-
references: map(configParseResult.projectReferences, r => ({ ...r, path: r.originalPath, originalPath: undefined })),
1787+
references: map(configParseResult.projectReferences, r => ({ ...r, path: r.originalPath ? r.originalPath : "", originalPath: undefined })),
17781788
files: length(files) ? files : undefined,
17791789
...(configParseResult.configFileSpecs ? {
17801790
include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs),
17811791
exclude: configParseResult.configFileSpecs.validatedExcludeSpecs
17821792
} : {}),
1783-
compilerOnSave: !!configParseResult.compileOnSave ? true : undefined
1793+
compileOnSave: !!configParseResult.compileOnSave ? true : undefined
17841794
};
17851795
return config;
17861796
}

src/testRunner/unittests/config/showConfig.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,26 @@ namespace ts {
5353

5454
showTSConfigCorrectly("Show TSConfig with advanced options", ["--showConfig", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"]);
5555

56+
showTSConfigCorrectly("Show TSConfig with compileOnSave and more", ["-p", "tsconfig.json"], {
57+
compilerOptions: {
58+
esModuleInterop: true,
59+
target: "es5",
60+
module: "commonjs",
61+
strict: true,
62+
},
63+
compileOnSave: true,
64+
exclude: [
65+
"dist"
66+
],
67+
files: [],
68+
include: [
69+
"src/*"
70+
],
71+
references: [
72+
{ path: "./test" }
73+
],
74+
});
75+
5676
// Regression test for https://github.com/Microsoft/TypeScript/issues/28836
5777
showTSConfigCorrectly("Show TSConfig with paths and more", ["-p", "tsconfig.json"], {
5878
compilerOptions: {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"esModuleInterop": true,
4+
"target": "es5",
5+
"module": "commonjs",
6+
"strict": true
7+
},
8+
"references": [
9+
{
10+
"path": "./test"
11+
}
12+
],
13+
"include": [
14+
"src/*"
15+
],
16+
"exclude": [
17+
"dist"
18+
],
19+
"compileOnSave": true
20+
}

0 commit comments

Comments
 (0)