Skip to content

Commit 012bacc

Browse files
a-tarasyukRyanCavanaugh
authored andcommitted
Define interface for TSConfig. Change compilerOnSave to compileOnSave (microsoft#32481)
1 parent 3c690f1 commit 012bacc

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
@@ -1743,14 +1743,24 @@ namespace ts {
17431743
return false;
17441744
}
17451745

1746+
/** @internal */
1747+
export interface TSConfig {
1748+
compilerOptions: CompilerOptions;
1749+
compileOnSave: boolean | undefined;
1750+
exclude?: ReadonlyArray<string>;
1751+
files: ReadonlyArray<string> | undefined;
1752+
include?: ReadonlyArray<string>;
1753+
references: ReadonlyArray<ProjectReference> | undefined;
1754+
}
1755+
17461756
/**
17471757
* Generate an uncommented, complete tsconfig for use with "--showConfig"
17481758
* @param configParseResult options to be generated into tsconfig.json
17491759
* @param configFileName name of the parsed config file - output paths will be generated relative to this
17501760
* @param host provides current directory and case sensitivity services
17511761
*/
17521762
/** @internal */
1753-
export function convertToTSConfig(configParseResult: ParsedCommandLine, configFileName: string, host: { getCurrentDirectory(): string, useCaseSensitiveFileNames: boolean }): object {
1763+
export function convertToTSConfig(configParseResult: ParsedCommandLine, configFileName: string, host: { getCurrentDirectory(): string, useCaseSensitiveFileNames: boolean }): TSConfig {
17541764
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
17551765
const files = map(
17561766
filter(
@@ -1778,13 +1788,13 @@ namespace ts {
17781788
build: undefined,
17791789
version: undefined,
17801790
},
1781-
references: map(configParseResult.projectReferences, r => ({ ...r, path: r.originalPath, originalPath: undefined })),
1791+
references: map(configParseResult.projectReferences, r => ({ ...r, path: r.originalPath ? r.originalPath : "", originalPath: undefined })),
17821792
files: length(files) ? files : undefined,
17831793
...(configParseResult.configFileSpecs ? {
17841794
include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs),
17851795
exclude: configParseResult.configFileSpecs.validatedExcludeSpecs
17861796
} : {}),
1787-
compilerOnSave: !!configParseResult.compileOnSave ? true : undefined
1797+
compileOnSave: !!configParseResult.compileOnSave ? true : undefined
17881798
};
17891799
return config;
17901800
}

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)