You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type alias preserving logic defeats complexity reduction mechanisms聽#54146
// Just a short block to make a union with > 300 unique membersexporttypeBit=0|1;exporttypeSyntaxKind= `${Bit}${Bit}${Bit}${Bit}${Bit}${Bit}${Bit}${Bit}${Bit}`
typeNodeMaker<TextendsSyntaxKind=SyntaxKind>=TextendsT ? {kind: T}: never;typeNode=NodeMaker;typeOk=Node&Node;typeNode2=NodeMaker;typeWat=Node&Node2;// fails to recognize Node and Node2 are identical, issues bogus complexity error
馃檨 Actual behavior
On the Wat declaration, we issue a complexity error, even though Node and Node2 are identical.
馃檪 Expected behavior
No complexity error, like on the Ok line.
The Wat case is actually easy to trigger in real code, as it's what happens in control flow when a type is removed and then readded to the control flow narrowed union - you get the same type, but with no alias information. I bring this up because we trivially trigger this same issue in a handful of places in our own union-ized code base.
Workaround
In type-space, none, sadly (short of eliminating the duplicated types). In expression-space, casting one of the expressions that's lost its' alias back to the aliased form can remove the error, though this feels bad, since the cast isn't well checked.
Activity