Skip to content

Commit ba0d77c

Browse files
committed
Get rid of NodeCheckFlags.InCheckIdentifier
1 parent 728064d commit ba0d77c

2 files changed

Lines changed: 12 additions & 18 deletions

File tree

src/compiler/checker.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30866,23 +30866,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3086630866
const parent = declaration.parent.parent;
3086730867
const rootDeclaration = getRootDeclaration(parent);
3086830868
if (rootDeclaration.kind === SyntaxKind.VariableDeclaration && getCombinedNodeFlagsCached(rootDeclaration) & NodeFlags.Constant || rootDeclaration.kind === SyntaxKind.Parameter) {
30869-
const links = getNodeLinks(parent);
30870-
if (!(links.flags & NodeCheckFlags.InCheckIdentifier)) {
30871-
links.flags |= NodeCheckFlags.InCheckIdentifier;
30872-
const parentType = getTypeForBindingElementParent(parent, CheckMode.Normal);
30873-
const parentTypeConstraint = parentType && mapType(parentType, getBaseConstraintOrType);
30874-
links.flags &= ~NodeCheckFlags.InCheckIdentifier;
30875-
if (parentTypeConstraint && parentTypeConstraint.flags & TypeFlags.Union && !(rootDeclaration.kind === SyntaxKind.Parameter && isSomeSymbolAssigned(rootDeclaration))) {
30876-
const pattern = declaration.parent;
30877-
const narrowedType = getFlowTypeOfReference(pattern, parentTypeConstraint, parentTypeConstraint, /*flowContainer*/ undefined, location.flowNode);
30878-
if (narrowedType.flags & TypeFlags.Never) {
30879-
return neverType;
30880-
}
30881-
// Destructurings are validated against the parent type elsewhere. Here we disable tuple bounds
30882-
// checks because the narrowed type may have lower arity than the full parent type. For example,
30883-
// for the declaration [x, y]: [1, 2] | [3], we may have narrowed the parent type to just [3].
30884-
return getBindingElementTypeFromParentType(declaration, narrowedType, /*noTupleBoundsCheck*/ true);
30869+
const parentType = getTypeForBindingElementParent(parent, CheckMode.Normal);
30870+
const parentTypeConstraint = parentType && mapType(parentType, getBaseConstraintOrType);
30871+
if (parentTypeConstraint && parentTypeConstraint.flags & TypeFlags.Union && !(rootDeclaration.kind === SyntaxKind.Parameter && isSomeSymbolAssigned(rootDeclaration))) {
30872+
const pattern = declaration.parent;
30873+
const narrowedType = getFlowTypeOfReference(pattern, parentTypeConstraint, parentTypeConstraint, /*flowContainer*/ undefined, location.flowNode);
30874+
if (narrowedType.flags & TypeFlags.Never) {
30875+
return neverType;
3088530876
}
30877+
// Destructurings are validated against the parent type elsewhere. Here we disable tuple bounds
30878+
// checks because the narrowed type may have lower arity than the full parent type. For example,
30879+
// for the declaration [x, y]: [1, 2] | [3], we may have narrowed the parent type to just [3].
30880+
return getBindingElementTypeFromParentType(declaration, narrowedType, /*noTupleBoundsCheck*/ true);
3088630881
}
3088730882
}
3088830883
}

src/compiler/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6240,8 +6240,7 @@ export const enum NodeCheckFlags {
62406240
ConstructorReference = 1 << 29, // Binding to a class constructor inside of the class's body.
62416241
ContainsClassWithPrivateIdentifiers = 1 << 20, // Marked on all block-scoped containers containing a class with private identifiers.
62426242
ContainsSuperPropertyInStaticInitializer = 1 << 21, // Marked on all block-scoped containers containing a static initializer with 'super.x' or 'super[x]'.
6243-
InCheckIdentifier = 1 << 22,
6244-
PartiallyTypeChecked = 1 << 23, // Node has been partially type checked
6243+
PartiallyTypeChecked = 1 << 22, // Node has been partially type checked
62456244

62466245
/** These flags are LazyNodeCheckFlags and can be calculated lazily by `hasNodeCheckFlag` */
62476246
LazyFlags = SuperInstance

0 commit comments

Comments
 (0)