mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-27 04:48:33 -05:00
Use custom type guard.
This commit is contained in:
@@ -6907,7 +6907,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isFunctionExpressionOrArrowFunction(node: Node): boolean {
|
||||
function isFunctionExpressionOrArrowFunction(node: Node): node is FunctionExpression {
|
||||
return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction;
|
||||
}
|
||||
|
||||
@@ -6926,8 +6926,8 @@ namespace ts {
|
||||
function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature {
|
||||
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
|
||||
let type = isObjectLiteralMethod(node)
|
||||
? getContextualTypeForObjectLiteralMethod(<MethodDeclaration>node)
|
||||
: getContextualType(<FunctionExpression>node);
|
||||
? getContextualTypeForObjectLiteralMethod(node)
|
||||
: getContextualType(node);
|
||||
if (!type) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -13656,7 +13656,7 @@ namespace ts {
|
||||
forEach(node.decorators, checkFunctionAndClassExpressionBodies);
|
||||
forEach((<MethodDeclaration>node).parameters, checkFunctionAndClassExpressionBodies);
|
||||
if (isObjectLiteralMethod(node)) {
|
||||
checkFunctionExpressionOrObjectLiteralMethodBody(<MethodDeclaration>node);
|
||||
checkFunctionExpressionOrObjectLiteralMethodBody(node);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.Constructor:
|
||||
|
||||
@@ -660,7 +660,7 @@ namespace ts {
|
||||
return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent);
|
||||
}
|
||||
|
||||
export function isObjectLiteralMethod(node: Node) {
|
||||
export function isObjectLiteralMethod(node: Node): node is MethodDeclaration {
|
||||
return node && node.kind === SyntaxKind.MethodDeclaration && node.parent.kind === SyntaxKind.ObjectLiteralExpression;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user