Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4e6586d

Browse filesBrowse files
committed
PR feedback
1 parent 15f9ea3 commit 4e6586d
Copy full SHA for 4e6586d

4 files changed

+11-16Lines changed: 11 additions & 16 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4719,8 +4719,7 @@ namespace ts {
47194719
}
47204720
// Handle export default expressions
47214721
if (isSourceFile(declaration)) {
4722-
Debug.assert(isJsonSourceFile(declaration));
4723-
const jsonSourceFile = <JsonSourceFile>declaration;
4722+
const jsonSourceFile = cast(declaration, isJsonSourceFile);
47244723
return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType;
47254724
}
47264725
if (declaration.kind === SyntaxKind.ExportAssignment) {
Collapse file

‎src/compiler/commandLineParser.ts‎

Copy file name to clipboardExpand all lines: src/compiler/commandLineParser.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,8 @@ namespace ts {
10761076

10771077
/**
10781078
* Convert the json syntax tree into the json value and report errors
1079+
* This returns the json value (apart from checking errors) only if returnValue provided is true.
1080+
* Otherwise it just checks the errors and returns undefined
10791081
*/
10801082
/*@internal*/
10811083
export function convertToObjectWorker(
Collapse file

‎src/compiler/program.ts‎

Copy file name to clipboardExpand all lines: src/compiler/program.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2433,7 +2433,7 @@ namespace ts {
24332433
switch (extension) {
24342434
case Extension.Ts:
24352435
case Extension.Dts:
2436-
case Extension.Json:
2436+
case Extension.Json: // Since module is resolved to json file only when --resolveJsonModule, we dont need further check
24372437
// These are always allowed.
24382438
return undefined;
24392439
case Extension.Tsx:
Collapse file

‎src/compiler/utilities.ts‎

Copy file name to clipboardExpand all lines: src/compiler/utilities.ts
+7-13Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,26 +1076,20 @@ namespace ts {
10761076
});
10771077
}
10781078

1079-
export function getTsConfigObjectLiteralExpression(tsConfigSourceFile: TsConfigSourceFile) {
1079+
export function getTsConfigObjectLiteralExpression(tsConfigSourceFile: TsConfigSourceFile | undefined) {
10801080
if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
10811081
const expression = tsConfigSourceFile.statements[0].expression;
10821082
return isObjectLiteralExpression(expression) && expression;
10831083
}
10841084
}
10851085

1086-
export function getTsConfigPropArrayElementValue(tsConfigSourceFile: TsConfigSourceFile, propKey: string, elementValue: string): StringLiteral {
1086+
export function getTsConfigPropArrayElementValue(tsConfigSourceFile: TsConfigSourceFile | undefined, propKey: string, elementValue: string): StringLiteral | undefined {
10871087
const jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile);
1088-
if (jsonObjectLiteral) {
1089-
for (const property of getPropertyAssignment(jsonObjectLiteral, propKey)) {
1090-
if (isArrayLiteralExpression(property.initializer)) {
1091-
for (const element of property.initializer.elements) {
1092-
if (isStringLiteral(element) && element.text === elementValue) {
1093-
return element;
1094-
}
1095-
}
1096-
}
1097-
}
1098-
}
1088+
return jsonObjectLiteral &&
1089+
firstDefined(getPropertyAssignment(jsonObjectLiteral, propKey), property =>
1090+
isArrayLiteralExpression(property.initializer) ?
1091+
find(property.initializer.elements, (element): element is StringLiteral => isStringLiteral(element) && element.text === elementValue) :
1092+
undefined);
10991093
}
11001094

11011095
export function getContainingFunction(node: Node): SignatureDeclaration {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.