mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 07:29:16 -05:00
Fixed false positive errors in empty optional binding patterns in declaration signatures (#50816)
This commit is contained in:
committed by
GitHub
parent
9c5b09cd21
commit
080f9c1c3f
@@ -25119,7 +25119,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
function isInAmbientOrTypeNode(node: Node): boolean {
|
||||
return !!(node.flags & NodeFlags.Ambient || findAncestor(node, n => isInterfaceDeclaration(n) || isTypeLiteralNode(n)));
|
||||
return !!(node.flags & NodeFlags.Ambient || findAncestor(node, n => isInterfaceDeclaration(n) || isTypeAliasDeclaration(n) || isTypeLiteralNode(n)));
|
||||
}
|
||||
|
||||
// Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers
|
||||
@@ -40653,6 +40653,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
// For a binding pattern, validate the initializer and exit
|
||||
if (isBindingPattern(node.name)) {
|
||||
if (isInAmbientOrTypeNode(node)) {
|
||||
return;
|
||||
}
|
||||
const needCheckInitializer = hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== SyntaxKind.ForInStatement;
|
||||
const needCheckWidenedType = !some(node.name.elements, not(isOmittedExpression));
|
||||
if (needCheckInitializer || needCheckWidenedType) {
|
||||
|
||||
Reference in New Issue
Block a user