Skip to content

Commit 3cca17e

Browse files
authored
Merge pull request #10676 from Microsoft/literalTypesAlways
Always use literal types
2 parents 2305c68 + ef81594 commit 3cca17e

File tree

2,203 files changed

+21274
-14155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,203 files changed

+21274
-14155
lines changed

src/compiler/binder.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,9 @@ namespace ts {
591591
case SyntaxKind.PrefixUnaryExpression:
592592
bindPrefixUnaryExpressionFlow(<PrefixUnaryExpression>node);
593593
break;
594+
case SyntaxKind.PostfixUnaryExpression:
595+
bindPostfixUnaryExpressionFlow(<PostfixUnaryExpression>node);
596+
break;
594597
case SyntaxKind.BinaryExpression:
595598
bindBinaryExpressionFlow(<BinaryExpression>node);
596599
break;
@@ -1106,6 +1109,16 @@ namespace ts {
11061109
}
11071110
else {
11081111
forEachChild(node, bind);
1112+
if (node.operator === SyntaxKind.PlusEqualsToken || node.operator === SyntaxKind.MinusMinusToken) {
1113+
bindAssignmentTargetFlow(node.operand);
1114+
}
1115+
}
1116+
}
1117+
1118+
function bindPostfixUnaryExpressionFlow(node: PostfixUnaryExpression) {
1119+
forEachChild(node, bind);
1120+
if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) {
1121+
bindAssignmentTargetFlow(node.operand);
11091122
}
11101123
}
11111124

src/compiler/checker.ts

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

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,10 +1063,6 @@
10631063
"category": "Error",
10641064
"code": 2353
10651065
},
1066-
"No best common type exists among return expressions.": {
1067-
"category": "Error",
1068-
"code": 2354
1069-
},
10701066
"A function whose declared type is neither 'void' nor 'any' must return a value.": {
10711067
"category": "Error",
10721068
"code": 2355
@@ -1631,10 +1627,6 @@
16311627
"category": "Error",
16321628
"code": 2503
16331629
},
1634-
"No best common type exists among yield expressions.": {
1635-
"category": "Error",
1636-
"code": 2504
1637-
},
16381630
"A generator cannot have a 'void' type annotation.": {
16391631
"category": "Error",
16401632
"code": 2505

src/compiler/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2593,13 +2593,14 @@ namespace ts {
25932593
export interface TypeInferences {
25942594
primary: Type[]; // Inferences made directly to a type parameter
25952595
secondary: Type[]; // Inferences made to a type parameter in a union type
2596+
topLevel: boolean; // True if all inferences were made from top-level (not nested in object type) locations
25962597
isFixed: boolean; // Whether the type parameter is fixed, as defined in section 4.12.2 of the TypeScript spec
25972598
// If a type parameter is fixed, no more inferences can be made for the type parameter
25982599
}
25992600

26002601
/* @internal */
26012602
export interface InferenceContext {
2602-
typeParameters: TypeParameter[]; // Type parameters for which inferences are made
2603+
signature: Signature; // Generic signature for which inferences are made
26032604
inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType)
26042605
inferences: TypeInferences[]; // Inferences made for each type parameter
26052606
inferredTypes: Type[]; // Inferred type for each type parameter

tests/baselines/reference/AmbientModuleAndAmbientWithSameNameAndCommonRoot.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ var p = new A.Point(0, 0); // unexpected error here, bug 840000
5656
>A.Point : typeof A.Point
5757
>A : typeof A
5858
>Point : typeof A.Point
59-
>0 : number
60-
>0 : number
59+
>0 : 0
60+
>0 : 0
6161

tests/baselines/reference/AmbientModuleAndNonAmbientClassWithSameNameAndCommonRoot.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ var p = new A.Point(0, 0); // unexpected error here, bug 840000
5050
>A.Point : typeof A.Point
5151
>A : typeof A
5252
>Point : typeof A.Point
53-
>0 : number
54-
>0 : number
53+
>0 : 0
54+
>0 : 0
5555

tests/baselines/reference/AmbientModuleAndNonAmbientFunctionWithTheSameNameAndCommonRoot.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function Point() {
1515
return { x: 0, y: 0 };
1616
>{ x: 0, y: 0 } : { x: number; y: number; }
1717
>x : number
18-
>0 : number
18+
>0 : 0
1919
>y : number
20-
>0 : number
20+
>0 : 0
2121
}
2222

2323
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===

tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ class Point {
1111
>Point : Point
1212
>{ x: 0, y: 0 } : { x: number; y: number; }
1313
>x : number
14-
>0 : number
14+
>0 : 0
1515
>y : number
16-
>0 : number
16+
>0 : 0
1717
}
1818

1919
module Point {
2020
>Point : typeof Point
2121

2222
function Origin() { return ""; }// not an error, since not exported
2323
>Origin : () => string
24-
>"" : string
24+
>"" : ""
2525
}
2626

2727

@@ -40,16 +40,16 @@ module A {
4040
>Point : Point
4141
>{ x: 0, y: 0 } : { x: number; y: number; }
4242
>x : number
43-
>0 : number
43+
>0 : 0
4444
>y : number
45-
>0 : number
45+
>0 : 0
4646
}
4747

4848
export module Point {
4949
>Point : typeof Point
5050

5151
function Origin() { return ""; }// not an error since not exported
5252
>Origin : () => string
53-
>"" : string
53+
>"" : ""
5454
}
5555
}

tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ class Point {
1111
>Point : Point
1212
>{ x: 0, y: 0 } : { x: number; y: number; }
1313
>x : number
14-
>0 : number
14+
>0 : 0
1515
>y : number
16-
>0 : number
16+
>0 : 0
1717
}
1818

1919
module Point {
2020
>Point : typeof Point
2121

2222
var Origin = ""; // not an error, since not exported
2323
>Origin : string
24-
>"" : string
24+
>"" : ""
2525
}
2626

2727

@@ -40,16 +40,16 @@ module A {
4040
>Point : Point
4141
>{ x: 0, y: 0 } : { x: number; y: number; }
4242
>x : number
43-
>0 : number
43+
>0 : 0
4444
>y : number
45-
>0 : number
45+
>0 : 0
4646
}
4747

4848
export module Point {
4949
>Point : typeof Point
5050

5151
var Origin = ""; // not an error since not exported
5252
>Origin : string
53-
>"" : string
53+
>"" : ""
5454
}
5555
}

tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ class C {
77

88
x = 10;
99
>x : number
10-
>10 : number
10+
>10 : 10
1111
}

0 commit comments

Comments
 (0)