mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Define interface for TSConfig. Change compilerOnSave to compileOnSave (#32481)
This commit is contained in:
parent
3c690f1264
commit
012bacc415
@ -1743,6 +1743,16 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface TSConfig {
|
||||
compilerOptions: CompilerOptions;
|
||||
compileOnSave: boolean | undefined;
|
||||
exclude?: ReadonlyArray<string>;
|
||||
files: ReadonlyArray<string> | undefined;
|
||||
include?: ReadonlyArray<string>;
|
||||
references: ReadonlyArray<ProjectReference> | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an uncommented, complete tsconfig for use with "--showConfig"
|
||||
* @param configParseResult options to be generated into tsconfig.json
|
||||
@ -1750,7 +1760,7 @@ namespace ts {
|
||||
* @param host provides current directory and case sensitivity services
|
||||
*/
|
||||
/** @internal */
|
||||
export function convertToTSConfig(configParseResult: ParsedCommandLine, configFileName: string, host: { getCurrentDirectory(): string, useCaseSensitiveFileNames: boolean }): object {
|
||||
export function convertToTSConfig(configParseResult: ParsedCommandLine, configFileName: string, host: { getCurrentDirectory(): string, useCaseSensitiveFileNames: boolean }): TSConfig {
|
||||
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
|
||||
const files = map(
|
||||
filter(
|
||||
@ -1778,13 +1788,13 @@ namespace ts {
|
||||
build: undefined,
|
||||
version: undefined,
|
||||
},
|
||||
references: map(configParseResult.projectReferences, r => ({ ...r, path: r.originalPath, originalPath: undefined })),
|
||||
references: map(configParseResult.projectReferences, r => ({ ...r, path: r.originalPath ? r.originalPath : "", originalPath: undefined })),
|
||||
files: length(files) ? files : undefined,
|
||||
...(configParseResult.configFileSpecs ? {
|
||||
include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs),
|
||||
exclude: configParseResult.configFileSpecs.validatedExcludeSpecs
|
||||
} : {}),
|
||||
compilerOnSave: !!configParseResult.compileOnSave ? true : undefined
|
||||
compileOnSave: !!configParseResult.compileOnSave ? true : undefined
|
||||
};
|
||||
return config;
|
||||
}
|
||||
|
||||
@ -53,6 +53,26 @@ namespace ts {
|
||||
|
||||
showTSConfigCorrectly("Show TSConfig with advanced options", ["--showConfig", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"]);
|
||||
|
||||
showTSConfigCorrectly("Show TSConfig with compileOnSave and more", ["-p", "tsconfig.json"], {
|
||||
compilerOptions: {
|
||||
esModuleInterop: true,
|
||||
target: "es5",
|
||||
module: "commonjs",
|
||||
strict: true,
|
||||
},
|
||||
compileOnSave: true,
|
||||
exclude: [
|
||||
"dist"
|
||||
],
|
||||
files: [],
|
||||
include: [
|
||||
"src/*"
|
||||
],
|
||||
references: [
|
||||
{ path: "./test" }
|
||||
],
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/Microsoft/TypeScript/issues/28836
|
||||
showTSConfigCorrectly("Show TSConfig with paths and more", ["-p", "tsconfig.json"], {
|
||||
compilerOptions: {
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"strict": true
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "./test"
|
||||
}
|
||||
],
|
||||
"include": [
|
||||
"src/*"
|
||||
],
|
||||
"exclude": [
|
||||
"dist"
|
||||
],
|
||||
"compileOnSave": true
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user