Skip to content

Commit 2aa97bd

Browse files
Use custom type guard.
1 parent 76da69c commit 2aa97bd

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/compiler/checker.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6907,7 +6907,7 @@ namespace ts {
69076907
}
69086908
}
69096909

6910-
function isFunctionExpressionOrArrowFunction(node: Node): boolean {
6910+
function isFunctionExpressionOrArrowFunction(node: Node): node is FunctionExpression {
69116911
return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction;
69126912
}
69136913

@@ -6926,8 +6926,8 @@ namespace ts {
69266926
function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature {
69276927
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
69286928
let type = isObjectLiteralMethod(node)
6929-
? getContextualTypeForObjectLiteralMethod(<MethodDeclaration>node)
6930-
: getContextualType(<FunctionExpression>node);
6929+
? getContextualTypeForObjectLiteralMethod(node)
6930+
: getContextualType(node);
69316931
if (!type) {
69326932
return undefined;
69336933
}
@@ -13656,7 +13656,7 @@ namespace ts {
1365613656
forEach(node.decorators, checkFunctionAndClassExpressionBodies);
1365713657
forEach((<MethodDeclaration>node).parameters, checkFunctionAndClassExpressionBodies);
1365813658
if (isObjectLiteralMethod(node)) {
13659-
checkFunctionExpressionOrObjectLiteralMethodBody(<MethodDeclaration>node);
13659+
checkFunctionExpressionOrObjectLiteralMethodBody(node);
1366013660
}
1366113661
break;
1366213662
case SyntaxKind.Constructor:

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ namespace ts {
660660
return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent);
661661
}
662662

663-
export function isObjectLiteralMethod(node: Node) {
663+
export function isObjectLiteralMethod(node: Node): node is MethodDeclaration {
664664
return node && node.kind === SyntaxKind.MethodDeclaration && node.parent.kind === SyntaxKind.ObjectLiteralExpression;
665665
}
666666

0 commit comments

Comments
 (0)