@@ -1278,7 +1278,7 @@ namespace ts {
1278
1278
isInExternalModule = true;
1279
1279
// falls through
1280
1280
case SyntaxKind.ModuleDeclaration:
1281
- const moduleExports = getSymbolOfNode(location)! .exports!;
1281
+ const moduleExports = getSymbolOfNode(location as ModuleDeclaration) .exports!;
1282
1282
if (location.kind === SyntaxKind.SourceFile || isAmbientModule(location)) {
1283
1283
1284
1284
// It's an external module. First see if the module has an export default and if the local
@@ -1340,7 +1340,7 @@ namespace ts {
1340
1340
case SyntaxKind.ClassDeclaration:
1341
1341
case SyntaxKind.ClassExpression:
1342
1342
case SyntaxKind.InterfaceDeclaration:
1343
- if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)! ), name, meaning & SymbolFlags.Type)) {
1343
+ if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location as ClassLikeDeclaration | InterfaceDeclaration) ), name, meaning & SymbolFlags.Type)) {
1344
1344
if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
1345
1345
// ignore type parameters not declared in this container
1346
1346
result = undefined;
@@ -1387,7 +1387,7 @@ namespace ts {
1387
1387
grandparent = location.parent.parent;
1388
1388
if (isClassLike(grandparent) || grandparent.kind === SyntaxKind.InterfaceDeclaration) {
1389
1389
// A reference to this grandparent's type parameters would be an error
1390
- if (result = lookup(getSymbolOfNode(grandparent)! .members!, name, meaning & SymbolFlags.Type)) {
1390
+ if (result = lookup(getSymbolOfNode(grandparent as ClassLikeDeclaration | InterfaceDeclaration) .members!, name, meaning & SymbolFlags.Type)) {
1391
1391
error(errorLocation, Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
1392
1392
return undefined;
1393
1393
}
@@ -2574,7 +2574,7 @@ namespace ts {
2574
2574
}
2575
2575
// falls through
2576
2576
case SyntaxKind.ModuleDeclaration:
2577
- if (result = callback(getSymbolOfNode(location)! .exports!)) {
2577
+ if (result = callback(getSymbolOfNode(location as ModuleDeclaration) .exports!)) {
2578
2578
return result;
2579
2579
}
2580
2580
break;
@@ -5036,7 +5036,7 @@ namespace ts {
5036
5036
const outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, getEffectiveTypeParameterDeclarations(<DeclarationWithTypeParameters>node) || emptyArray);
5037
5037
const thisType = includeThisTypes &&
5038
5038
(node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.InterfaceDeclaration) &&
5039
- getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)! ).thisType;
5039
+ getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node as ClassLikeDeclaration | InterfaceDeclaration) ).thisType;
5040
5040
return thisType ? append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters;
5041
5041
}
5042
5042
}
@@ -9088,7 +9088,7 @@ namespace ts {
9088
9088
9089
9089
function getESSymbolLikeTypeForNode(node: Node) {
9090
9090
if (isValidESSymbolDeclaration(node)) {
9091
- const symbol = getSymbolOfNode(node)! ;
9091
+ const symbol = getSymbolOfNode(node);
9092
9092
const links = getSymbolLinks(symbol);
9093
9093
return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
9094
9094
}
@@ -9101,7 +9101,7 @@ namespace ts {
9101
9101
if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) {
9102
9102
if (!hasModifier(container, ModifierFlags.Static) &&
9103
9103
(container.kind !== SyntaxKind.Constructor || isNodeDescendantOf(node, (<ConstructorDeclaration>container).body!))) {
9104
- return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)! ).thisType!;
9104
+ return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent as ClassLikeDeclaration | InterfaceDeclaration) ).thisType!;
9105
9105
}
9106
9106
}
9107
9107
error(node, Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
@@ -17773,7 +17773,7 @@ namespace ts {
17773
17773
if (node.kind === SyntaxKind.ClassDeclaration) {
17774
17774
// For a class decorator, the `target` is the type of the class (e.g. the
17775
17775
// "static" or "constructor" side of the class)
17776
- const classSymbol = getSymbolOfNode(node)! ;
17776
+ const classSymbol = getSymbolOfNode(node as ClassDeclaration) ;
17777
17777
return getTypeOfSymbol(classSymbol);
17778
17778
}
17779
17779
@@ -17782,7 +17782,7 @@ namespace ts {
17782
17782
// parameter's containing method.
17783
17783
node = node.parent;
17784
17784
if (node.kind === SyntaxKind.Constructor) {
17785
- const classSymbol = getSymbolOfNode(node)! ;
17785
+ const classSymbol = getSymbolOfNode(node as ConstructorDeclaration) ;
17786
17786
return getTypeOfSymbol(classSymbol);
17787
17787
}
17788
17788
}
@@ -18958,7 +18958,7 @@ namespace ts {
18958
18958
return unknownType;
18959
18959
}
18960
18960
else if (container.kind === SyntaxKind.Constructor) {
18961
- const symbol = getSymbolOfNode(container.parent)! ;
18961
+ const symbol = getSymbolOfNode(container.parent as ClassLikeDeclaration) ;
18962
18962
return getTypeOfSymbol(symbol);
18963
18963
}
18964
18964
else {
@@ -20944,7 +20944,7 @@ namespace ts {
20944
20944
20945
20945
function checkTypeForDuplicateIndexSignatures(node: Node) {
20946
20946
if (node.kind === SyntaxKind.InterfaceDeclaration) {
20947
- const nodeSymbol = getSymbolOfNode(node)! ;
20947
+ const nodeSymbol = getSymbolOfNode(node as InterfaceDeclaration) ;
20948
20948
// in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration
20949
20949
// to prevent this run check only for the first declaration of a given kind
20950
20950
if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) {
@@ -24187,7 +24187,7 @@ namespace ts {
24187
24187
if (isInstancePropertyWithoutInitializer(member)) {
24188
24188
const propName = (<PropertyDeclaration>member).name;
24189
24189
if (isIdentifier(propName)) {
24190
- const type = getTypeOfSymbol(getSymbolOfNode(member)); // TODO: GH#18217
24190
+ const type = getTypeOfSymbol(getSymbolOfNode(member));
24191
24191
if (!(type.flags & TypeFlags.Any || getFalsyFlags(type) & TypeFlags.Undefined)) {
24192
24192
if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
24193
24193
error(member.name, Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, declarationNameToString(propName));
@@ -25412,13 +25412,13 @@ namespace ts {
25412
25412
25413
25413
switch (location.kind) {
25414
25414
case SyntaxKind.ModuleDeclaration:
25415
- copySymbols(getSymbolOfNode(location)! .exports!, meaning & SymbolFlags.ModuleMember);
25415
+ copySymbols(getSymbolOfNode(location as ModuleDeclaration) .exports!, meaning & SymbolFlags.ModuleMember);
25416
25416
break;
25417
25417
case SyntaxKind.EnumDeclaration:
25418
- copySymbols(getSymbolOfNode(location)! .exports!, meaning & SymbolFlags.EnumMember);
25418
+ copySymbols(getSymbolOfNode(location as EnumDeclaration) .exports!, meaning & SymbolFlags.EnumMember);
25419
25419
break;
25420
25420
case SyntaxKind.ClassExpression:
25421
- const className = (<ClassExpression> location).name;
25421
+ const className = (location as ClassExpression ).name;
25422
25422
if (className) {
25423
25423
copySymbol(location.symbol, meaning);
25424
25424
}
@@ -25432,11 +25432,11 @@ namespace ts {
25432
25432
// (type parameters of classDeclaration/classExpression and interface are in member property of the symbol.
25433
25433
// Note: that the memberFlags come from previous iteration.
25434
25434
if (!isStatic) {
25435
- copySymbols(getMembersOfSymbol(getSymbolOfNode(location)! ), meaning & SymbolFlags.Type);
25435
+ copySymbols(getMembersOfSymbol(getSymbolOfNode(location as ClassDeclaration | InterfaceDeclaration) ), meaning & SymbolFlags.Type);
25436
25436
}
25437
25437
break;
25438
25438
case SyntaxKind.FunctionExpression:
25439
- const funcName = (<FunctionExpression> location).name;
25439
+ const funcName = (location as FunctionExpression ).name;
25440
25440
if (funcName) {
25441
25441
copySymbol(location.symbol, meaning);
25442
25442
}
@@ -25488,7 +25488,7 @@ namespace ts {
25488
25488
(<NamedDeclaration>name.parent).name === name;
25489
25489
}
25490
25490
25491
- function isTypeDeclaration(node: Node): boolean {
25491
+ function isTypeDeclaration(node: Node): node is TypeParameterDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumDeclaration {
25492
25492
switch (node.kind) {
25493
25493
case SyntaxKind.TypeParameter:
25494
25494
case SyntaxKind.ClassDeclaration:
@@ -25864,7 +25864,7 @@ namespace ts {
25864
25864
25865
25865
if (isTypeDeclaration(node)) {
25866
25866
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
25867
- const symbol = getSymbolOfNode(node)! ;
25867
+ const symbol = getSymbolOfNode(node);
25868
25868
return getDeclaredTypeOfSymbol(symbol);
25869
25869
}
25870
25870
0 commit comments