Skip to content

Commit f85c772

Browse files
committed
Fixed formatting and edited a test
1 parent 5ba95f7 commit f85c772

File tree

8 files changed

+340
-387
lines changed

8 files changed

+340
-387
lines changed

src/compiler/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ function getBuildInfo(state: BuilderProgramState, getCanonicalFileName: GetCanon
11161116

11171117
function convertToReusableCompilerOptionValue(option: CommandLineOption | undefined, value: CompilerOptionsValue, relativeToBuildInfo: (path: string) => string) {
11181118
if (option) {
1119-
Debug.assert(option.type !== "listOrElement");
1119+
Debug.assert(option.type !== "listOrElement");
11201120
if (option.type === "list") {
11211121
const values = value as readonly (string | number)[];
11221122
if (option.element.isFilePath && values.length) {

src/compiler/commandLineParser.ts

Lines changed: 186 additions & 186 deletions
Large diffs are not rendered by default.

src/executeCommandLine/executeCommandLine.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,16 @@ function generateOptionOutput(sys: System, option: CommandLineOption, rightAlign
177177
// name and description
178178
const name = getDisplayNameTextOfOption(option);
179179

180-
// value type and possible value
181-
const valueCandidates = getValueCandidate(option);
182-
const defaultValueDescription =
183-
typeof option.defaultValueDescription === "object"
184-
? getDiagnosticText(option.defaultValueDescription)
185-
: formatDefaultValue(
186-
option.defaultValueDescription,
187-
option.type === "list" || option.type === "listOrElement" ? option.element.type : option.type
188-
);
189-
const terminalWidth = sys.getWidthOfTerminal?.() ?? 0;
180+
// value type and possible value
181+
const valueCandidates = getValueCandidate(option);
182+
const defaultValueDescription =
183+
typeof option.defaultValueDescription === "object"
184+
? getDiagnosticText(option.defaultValueDescription)
185+
: formatDefaultValue(
186+
option.defaultValueDescription,
187+
option.type === "list" || option.type === "listOrElement" ? option.element.type : option.type
188+
);
189+
const terminalWidth = sys.getWidthOfTerminal?.() ?? 0;
190190

191191
// Note: child_process might return `terminalWidth` as undefined.
192192
if (terminalWidth >= 80) {
@@ -295,7 +295,7 @@ function generateOptionOutput(sys: System, option: CommandLineOption, rightAlign
295295
};
296296

297297
function getValueType(option: CommandLineOption) {
298-
Debug.assert(option.type !== "listOrElement");
298+
Debug.assert(option.type !== "listOrElement");
299299
switch (option.type) {
300300
case "string":
301301
case "number":
@@ -308,34 +308,34 @@ function generateOptionOutput(sys: System, option: CommandLineOption, rightAlign
308308
}
309309
}
310310

311-
function getPossibleValues(option: CommandLineOption) {
312-
let possibleValues: string;
313-
switch (option.type) {
314-
case "string":
315-
case "number":
316-
case "boolean":
317-
possibleValues = option.type;
318-
break;
319-
case "list":
320-
case "listOrElement":
321-
possibleValues = getPossibleValues(option.element);
322-
break;
323-
case "object":
324-
possibleValues = "";
325-
break;
326-
default:
327-
// ESMap<string, number | string>
328-
// Group synonyms: es6/es2015
329-
const inverted: { [value: string]: string[] } = {};
330-
option.type.forEach((value, name) => {
331-
(inverted[value] ||= []).push(name);
332-
});
333-
return getEntries(inverted)
334-
.map(([, synonyms]) => synonyms.join("/"))
335-
.join(", ");
336-
}
337-
return possibleValues;
311+
function getPossibleValues(option: CommandLineOption) {
312+
let possibleValues: string;
313+
switch (option.type) {
314+
case "string":
315+
case "number":
316+
case "boolean":
317+
possibleValues = option.type;
318+
break;
319+
case "list":
320+
case "listOrElement":
321+
possibleValues = getPossibleValues(option.element);
322+
break;
323+
case "object":
324+
possibleValues = "";
325+
break;
326+
default:
327+
// ESMap<string, number | string>
328+
// Group synonyms: es6/es2015
329+
const inverted: { [value: string]: string[] } = {};
330+
option.type.forEach((value, name) => {
331+
(inverted[value] ||= []).push(name);
332+
});
333+
return getEntries(inverted)
334+
.map(([, synonyms]) => synonyms.join("/"))
335+
.join(", ");
338336
}
337+
return possibleValues;
338+
}
339339
}
340340
}
341341

src/services/getEditsForFileRename.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,25 @@ function updateTsconfigFiles(program: Program, changeTracker: textChanges.Change
8787
}
8888
return;
8989
}
90-
case "compilerOptions":
91-
forEachProperty(property.initializer, (property, propertyName) => {
92-
const option = getOptionFromName(propertyName);
93-
Debug.assert(option?.type !== "listOrElement");
94-
if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) {
95-
updatePaths(property);
96-
}
97-
else if (propertyName === "paths") {
98-
forEachProperty(property.initializer, (pathsProperty) => {
99-
if (!isArrayLiteralExpression(pathsProperty.initializer)) return;
100-
for (const e of pathsProperty.initializer.elements) {
101-
tryUpdateString(e);
102-
}
103-
});
104-
}
105-
});
106-
return;
107-
}
108-
});
90+
case "compilerOptions":
91+
forEachProperty(property.initializer, (property, propertyName) => {
92+
const option = getOptionFromName(propertyName);
93+
Debug.assert(option?.type !== "listOrElement");
94+
if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) {
95+
updatePaths(property);
96+
}
97+
else if (propertyName === "paths") {
98+
forEachProperty(property.initializer, (pathsProperty) => {
99+
if (!isArrayLiteralExpression(pathsProperty.initializer)) return;
100+
for (const e of pathsProperty.initializer.elements) {
101+
tryUpdateString(e);
102+
}
103+
});
104+
}
105+
});
106+
return;
107+
}
108+
});
109109

110110
function updatePaths(property: PropertyAssignment): boolean {
111111
const elements = isArrayLiteralExpression(property.initializer) ? property.initializer.elements : [property.initializer];

src/testRunner/unittests/config/configurationExtension.ts

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -378,54 +378,54 @@ describe("unittests:: config:: configurationExtension", () => {
378378
testSuccess("can lookup via an implicit tsconfig in a package-relative directory with extension", "tsconfig.extendsBoxImpliedPath.json", { strict: true }, [ts.combinePaths(basePath, "main.ts")]);
379379
});
380380

381-
it("adds extendedSourceFiles only once", () => {
382-
const sourceFile = ts.readJsonConfigFile("configs/fourth.json", (path) => host.readFile(path));
383-
const dir = ts.combinePaths(basePath, "configs");
384-
const expected = [
385-
ts.combinePaths(dir, "third.json"),
386-
ts.combinePaths(dir, "second.json"),
387-
ts.combinePaths(dir, "base.json"),
388-
];
389-
ts.parseJsonSourceFileConfigFileContent(sourceFile, host, dir, {}, "fourth.json");
390-
assert.deepEqual(sourceFile.extendedSourceFiles, expected);
391-
ts.parseJsonSourceFileConfigFileContent(sourceFile, host, dir, {}, "fourth.json");
392-
assert.deepEqual(sourceFile.extendedSourceFiles, expected);
393-
});
381+
it("adds extendedSourceFiles only once", () => {
382+
const sourceFile = ts.readJsonConfigFile("configs/fourth.json", (path) => host.readFile(path));
383+
const dir = ts.combinePaths(basePath, "configs");
384+
const expected = [
385+
ts.combinePaths(dir, "third.json"),
386+
ts.combinePaths(dir, "second.json"),
387+
ts.combinePaths(dir, "base.json"),
388+
];
389+
ts.parseJsonSourceFileConfigFileContent(sourceFile, host, dir, {}, "fourth.json");
390+
assert.deepEqual(sourceFile.extendedSourceFiles, expected);
391+
ts.parseJsonSourceFileConfigFileContent(sourceFile, host, dir, {}, "fourth.json");
392+
assert.deepEqual(sourceFile.extendedSourceFiles, expected);
394393
});
394+
});
395395

396-
describe(testName, () => {
397-
it("adds extendedSourceFiles from an array only once", () => {
398-
const sourceFile = ts.readJsonConfigFile("configs/extendsArrayFifth.json", (path) => host.readFile(path));
399-
const dir = ts.combinePaths(basePath, "configs");
400-
const expected = [
401-
ts.combinePaths(dir, "extendsArrayFirst.json"),
402-
ts.combinePaths(dir, "extendsArraySecond.json"),
403-
ts.combinePaths(dir, "extendsArrayThird.json"),
404-
ts.combinePaths(dir, "extendsArrayFourth.json"),
405-
];
406-
ts.parseJsonSourceFileConfigFileContent(sourceFile, host, dir, {}, "extendsArrayFifth.json");
407-
assert.deepEqual(sourceFile.extendedSourceFiles, expected);
408-
ts.parseJsonSourceFileConfigFileContent(sourceFile, host, dir, {}, "extendsArrayFifth.json");
409-
assert.deepEqual(sourceFile.extendedSourceFiles, expected);
410-
});
396+
describe(testName, () => {
397+
it("adds extendedSourceFiles from an array only once", () => {
398+
const sourceFile = ts.readJsonConfigFile("configs/extendsArrayFifth.json", (path) => host.readFile(path));
399+
const dir = ts.combinePaths(basePath, "configs");
400+
const expected = [
401+
ts.combinePaths(dir, "extendsArrayFirst.json"),
402+
ts.combinePaths(dir, "extendsArraySecond.json"),
403+
ts.combinePaths(dir, "extendsArrayThird.json"),
404+
ts.combinePaths(dir, "extendsArrayFourth.json"),
405+
];
406+
ts.parseJsonSourceFileConfigFileContent(sourceFile, host, dir, {}, "extendsArrayFifth.json");
407+
assert.deepEqual(sourceFile.extendedSourceFiles, expected);
408+
ts.parseJsonSourceFileConfigFileContent(sourceFile, host, dir, {}, "extendsArrayFifth.json");
409+
assert.deepEqual(sourceFile.extendedSourceFiles, expected);
410+
});
411411

412-
testSuccess("can overwrite top-level compilerOptions", "configs/extendsArrayFifth.json", {
413-
allowJs: true,
414-
noImplicitAny: false,
415-
strictNullChecks: false,
416-
module: ts.ModuleKind.System
417-
}, []);
412+
testSuccess("can overwrite top-level compilerOptions", "configs/extendsArrayFifth.json", {
413+
allowJs: true,
414+
noImplicitAny: false,
415+
strictNullChecks: false,
416+
module: ts.ModuleKind.System
417+
}, []);
418418

419-
testFailure("can report missing configurations", "extendsArrayFails.json", [{
420-
code: 6053,
421-
messageText: `File './missingFile' not found.`
422-
}]);
419+
testFailure("can report missing configurations", "extendsArrayFails.json", [{
420+
code: 6053,
421+
messageText: `File './missingFile' not found.`
422+
}]);
423423

424-
testFailure("can error when 'extends' is not a string or Array2", "extendsArrayFails2.json", [{
425-
code: 5024,
426-
messageText: `Compiler option 'extends' requires a value of type string.`
427-
}]);
428-
});
424+
testFailure("can error when 'extends' is not a string or Array2", "extendsArrayFails2.json", [{
425+
code: 5024,
426+
messageText: `Compiler option 'extends' requires a value of type string.`
427+
}]);
429428
});
430429
});
430+
});
431431

src/testRunner/unittests/config/showConfig.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ describe("unittests:: config:: showConfig", () => {
147147
}
148148
break;
149149
}
150-
case "listOrElement": {
151-
ts.Debug.fail();
152-
break;
153-
}
150+
case "listOrElement": {
151+
ts.Debug.fail();
152+
break;
153+
}
154154
case "string": {
155155
if (option.isTSConfigOnly) {
156156
args = ["-p", "tsconfig.json"];

src/testRunner/unittests/tsbuildWatch/programUpdates.ts

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -618,44 +618,44 @@ export function someFn() { }`),
618618
files: [otherFile.path]
619619
})
620620
};
621-
const otherFile2: File = {
622-
path: "/a/b/other2.ts",
623-
content: "let k = 0;",
624-
};
625-
const extendsConfigFile1: File = {
626-
path: "/a/b/extendsConfig1.tsconfig.json",
627-
content: JSON.stringify({
628-
compilerOptions: {
629-
composite: true,
630-
}
631-
})
632-
};
633-
const extendsConfigFile2: File = {
634-
path: "/a/b/extendsConfig2.tsconfig.json",
635-
content: JSON.stringify({
636-
compilerOptions: {
637-
strictNullChecks: false,
638-
}
639-
})
640-
};
641-
const extendsConfigFile3: File = {
642-
path: "/a/b/extendsConfig3.tsconfig.json",
643-
content: JSON.stringify({
644-
compilerOptions: {
645-
noImplicitAny: true,
646-
}
647-
})
648-
};
649-
const project3Config: File = {
650-
path: "/a/b/project3.tsconfig.json",
651-
content: JSON.stringify({
652-
extends: ["./extendsConfig1.tsconfig.json", "./extendsConfig2.tsconfig.json", "./extendsConfig3.tsconfig.json"],
653-
compilerOptions: {
654-
composite: false,
655-
},
656-
files: [otherFile2.path]
657-
})
658-
};
621+
const otherFile2: File = {
622+
path: "/a/b/other2.ts",
623+
content: "let k = 0;",
624+
};
625+
const extendsConfigFile1: File = {
626+
path: "/a/b/extendsConfig1.tsconfig.json",
627+
content: JSON.stringify({
628+
compilerOptions: {
629+
composite: true,
630+
}
631+
})
632+
};
633+
const extendsConfigFile2: File = {
634+
path: "/a/b/extendsConfig2.tsconfig.json",
635+
content: JSON.stringify({
636+
compilerOptions: {
637+
strictNullChecks: false,
638+
}
639+
})
640+
};
641+
const extendsConfigFile3: File = {
642+
path: "/a/b/extendsConfig3.tsconfig.json",
643+
content: JSON.stringify({
644+
compilerOptions: {
645+
noImplicitAny: true,
646+
}
647+
})
648+
};
649+
const project3Config: File = {
650+
path: "/a/b/project3.tsconfig.json",
651+
content: JSON.stringify({
652+
extends: ["./extendsConfig1.tsconfig.json", "./extendsConfig2.tsconfig.json", "./extendsConfig3.tsconfig.json"],
653+
compilerOptions: {
654+
composite: false,
655+
},
656+
files: [otherFile2.path]
657+
})
658+
};
659659
return createWatchedSystem([
660660
libFile,
661661
alphaExtendedConfigFile, project1Config, commonFile1, commonFile2,
@@ -727,6 +727,7 @@ export function someFn() { }`),
727727
caption: "Modify project 3",
728728
change: sys => sys.writeFile("/a/b/project3.tsconfig.json", JSON.stringify({
729729
extends: ["./extendsConfig1.tsconfig.json", "./extendsConfig2.tsconfig.json"],
730+
compilerOptions: { composite: false },
730731
files: ["/a/b/other2.ts"]
731732
})),
732733
timeouts: sys => { // Build project3

0 commit comments

Comments
 (0)