Skip to content

Fix typo in convertToTSConfig #32706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1743,6 +1743,17 @@ namespace ts {
return false;
}

interface TsConfigJson {
compilerOptions?: OptionsBase;
references?: readonly ProjectReference[];
files?: readonly string[];
include?: readonly string[];
exclude?: readonly string[];
compileOnSave?: boolean;
extends?: string;
typeAcquisition?: TypeAcquisition;
}

/**
* Generate an uncommented, complete tsconfig for use with "--showConfig"
* @param configParseResult options to be generated into tsconfig.json
Expand All @@ -1764,7 +1775,7 @@ namespace ts {
f => getRelativePathFromFile(getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName)
);
const optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames });
const config = {
const config: TsConfigJson = {
compilerOptions: {
...arrayFrom(optionMap.entries()).reduce((prev, cur) => ({ ...prev, [cur[0]]: cur[1] }), {}),
showConfig: undefined,
Expand All @@ -1778,13 +1789,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!, 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;
}
Expand Down
53 changes: 27 additions & 26 deletions src/testRunner/unittests/config/showConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,33 @@ namespace ts {

// Regression test for https://github.com/Microsoft/TypeScript/issues/28836
showTSConfigCorrectly("Show TSConfig with paths and more", ["-p", "tsconfig.json"], {
compilerOptions: {
allowJs: true,
outDir: "./lib",
esModuleInterop: true,
module: "commonjs",
moduleResolution: "node",
target: "ES2017",
sourceMap: true,
baseUrl: ".",
paths: {
"@root/*": ["./*"],
"@configs/*": ["src/configs/*"],
"@common/*": ["src/common/*"],
"*": [
"node_modules/*",
"src/types/*"
]
},
experimentalDecorators: true,
emitDecoratorMetadata: true,
resolveJsonModule: true
},
include: [
"./src/**/*"
]
});
compilerOptions: {
allowJs: true,
outDir: "./lib",
esModuleInterop: true,
module: "commonjs",
moduleResolution: "node",
target: "ES2017",
sourceMap: true,
baseUrl: ".",
paths: {
"@root/*": ["./*"],
"@configs/*": ["src/configs/*"],
"@common/*": ["src/common/*"],
"*": [
"node_modules/*",
"src/types/*"
]
},
experimentalDecorators: true,
emitDecoratorMetadata: true,
resolveJsonModule: true
},
include: [
"./src/**/*"
],
compileOnSave: true
});

// Bulk validation of all option declarations
for (const option of optionDeclarations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
],
"exclude": [
"./lib"
]
],
"compileOnSave": true
}