@@ -60,18 +60,8 @@ namespace ts {
60
60
getDiagnostics,
61
61
getGlobalDiagnostics,
62
62
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.
75
65
getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol,
76
66
getDeclaredTypeOfSymbol,
77
67
getPropertiesOfType,
@@ -215,7 +205,9 @@ namespace ts {
215
205
let assignableRelation: Map<RelationComparisonResult> = {};
216
206
let identityRelation: Map<RelationComparisonResult> = {};
217
207
218
- enum TypeSystemPropertyName {
208
+ type TypeSystemEntity = Symbol | Type | Signature;
209
+
210
+ const enum TypeSystemPropertyName {
219
211
Type,
220
212
ResolvedBaseConstructorType,
221
213
DeclaredType,
@@ -2242,18 +2234,18 @@ namespace ts {
2242
2234
if (propertyName === TypeSystemPropertyName.Type) {
2243
2235
return getSymbolLinks(<Symbol>target).type;
2244
2236
}
2245
- else if (propertyName === TypeSystemPropertyName.DeclaredType) {
2237
+ if (propertyName === TypeSystemPropertyName.DeclaredType) {
2246
2238
return getSymbolLinks(<Symbol>target).declaredType;
2247
2239
}
2248
- else if (propertyName === TypeSystemPropertyName.ResolvedBaseConstructorType) {
2240
+ if (propertyName === TypeSystemPropertyName.ResolvedBaseConstructorType) {
2249
2241
Debug.assert(!!((<Type>target).flags & TypeFlags.Class));
2250
2242
return (<InterfaceType>target).resolvedBaseConstructorType;
2251
2243
}
2252
- else if (propertyName === TypeSystemPropertyName.ResolvedReturnType) {
2244
+ if (propertyName === TypeSystemPropertyName.ResolvedReturnType) {
2253
2245
return (<Signature>target).resolvedReturnType;
2254
2246
}
2255
2247
2256
- Debug.fail("Unhandled TypeSystemObjectKind" );
2248
+ Debug.fail("Unhandled TypeSystemPropertyName " + propertyName );
2257
2249
}
2258
2250
2259
2251
// Pop an entry from the type resolution stack and return its associated result value. The result value will
0 commit comments