Skip to content

Commit 05bc4fe

Browse files
committed
Address PR feedback
1 parent e2303b1 commit 05bc4fe

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/compiler/checker.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,8 @@ namespace ts {
6060
getDiagnostics,
6161
getGlobalDiagnostics,
6262

63-
// Get the narrowed type of symbol at given location instead of just getting
64-
// the type of the symbol.
65-
// eg.
66-
// function foo(a: string | number) {
67-
// if (typeof a === "string") {
68-
// a/**/
69-
// }
70-
// }
71-
// getTypeOfSymbol for a would return type of parameter symbol string | number
72-
// Unless we provide location /**/, checker wouldn't know how to narrow the type
73-
// By using getNarrowedTypeOfSymbol would return string since it would be able to narrow
74-
// it by typeguard in the if true condition
63+
// The language service will always care about the narrowed type of a symbol, because that is
64+
// the type the language says the symbol should have.
7565
getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol,
7666
getDeclaredTypeOfSymbol,
7767
getPropertiesOfType,
@@ -215,7 +205,9 @@ namespace ts {
215205
let assignableRelation: Map<RelationComparisonResult> = {};
216206
let identityRelation: Map<RelationComparisonResult> = {};
217207

218-
enum TypeSystemPropertyName {
208+
type TypeSystemEntity = Symbol | Type | Signature;
209+
210+
const enum TypeSystemPropertyName {
219211
Type,
220212
ResolvedBaseConstructorType,
221213
DeclaredType,
@@ -2242,18 +2234,18 @@ namespace ts {
22422234
if (propertyName === TypeSystemPropertyName.Type) {
22432235
return getSymbolLinks(<Symbol>target).type;
22442236
}
2245-
else if (propertyName === TypeSystemPropertyName.DeclaredType) {
2237+
if (propertyName === TypeSystemPropertyName.DeclaredType) {
22462238
return getSymbolLinks(<Symbol>target).declaredType;
22472239
}
2248-
else if (propertyName === TypeSystemPropertyName.ResolvedBaseConstructorType) {
2240+
if (propertyName === TypeSystemPropertyName.ResolvedBaseConstructorType) {
22492241
Debug.assert(!!((<Type>target).flags & TypeFlags.Class));
22502242
return (<InterfaceType>target).resolvedBaseConstructorType;
22512243
}
2252-
else if (propertyName === TypeSystemPropertyName.ResolvedReturnType) {
2244+
if (propertyName === TypeSystemPropertyName.ResolvedReturnType) {
22532245
return (<Signature>target).resolvedReturnType;
22542246
}
22552247

2256-
Debug.fail("Unhandled TypeSystemObjectKind");
2248+
Debug.fail("Unhandled TypeSystemPropertyName " + propertyName);
22572249
}
22582250

22592251
// Pop an entry from the type resolution stack and return its associated result value. The result value will

src/compiler/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,8 +1904,6 @@ namespace ts {
19041904
isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison
19051905
}
19061906

1907-
export type TypeSystemEntity = Symbol | Type | Signature;
1908-
19091907
export const enum IndexKind {
19101908
String,
19111909
Number,

0 commit comments

Comments
 (0)