Skip to content

Commit 76fbe25

Browse files
committed
Limit calls to isSymbolAssigned
1 parent dd07cdc commit 76fbe25

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24851,15 +24851,15 @@ namespace ts {
2485124851
// as if it occurred in the specified location. We then recompute the narrowed binding element type by
2485224852
// destructuring from the narrowed parent type.
2485324853
const declaration = symbol.valueDeclaration;
24854-
if (declaration && isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken) {
24854+
if (declaration && isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
2485524855
const parent = declaration.parent.parent;
24856-
if (parent.kind === SyntaxKind.VariableDeclaration && getCombinedNodeFlags(declaration) && NodeFlags.Const || parent.kind === SyntaxKind.Parameter && !isSymbolAssigned(symbol)) {
24856+
if (parent.kind === SyntaxKind.VariableDeclaration && getCombinedNodeFlags(declaration) && NodeFlags.Const || parent.kind === SyntaxKind.Parameter) {
2485724857
const links = getNodeLinks(location);
2485824858
if (!(links.flags & NodeCheckFlags.InCheckIdentifier)) {
2485924859
links.flags |= NodeCheckFlags.InCheckIdentifier;
2486024860
const parentType = getTypeForBindingElementParent(parent);
2486124861
links.flags &= ~NodeCheckFlags.InCheckIdentifier;
24862-
if (parentType && parentType.flags & TypeFlags.Union) {
24862+
if (parentType && parentType.flags & TypeFlags.Union && !(parent.kind === SyntaxKind.Parameter && isSymbolAssigned(symbol))) {
2486324863
const pattern = declaration.parent;
2486424864
const narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
2486524865
return getBindingElementTypeFromParentType(declaration, narrowedType);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy