Bug Report
🔎 Search Terms
reduction, generic, union, intersection
🕗 Version & Regression Information
This bug is also the 'Nightly' version. Versions prior to 4.6.2 give even more errors.
⏯ Playground Link
Playground link with relevant code
💻 Code
typeNumericLiteral={value: number;type: "NumericLiteral";};typeStringLiteral={value: string;type: "StringLiteral";};typeIdentifier={name: string;type: "Identifier";};typeCallExpression={name: string;arguments: DropbearNode[];type: "CallExpression";};typeDropbearNode=|NumericLiteral|StringLiteral|Identifier|CallExpression;typeVisitor={[KinDropbearNode["type"]]: (node: Extract<DropbearNode,{type: K}>)=>void};functionvisitNode<KextendsDropbearNode['type']>(node: Extract<DropbearNode,{type: K}>,v: Visitor){v[node.type](node)// error}🙁 Actual behavior
typeof node.type is inferred as (K & "NumericLiteral") | (K & "StringLiteral") | (K & "Identifier") | (K & "CallExpression") that it is equal to K itself considering that K extends "NumericLiteral" | "StringLiteral" | "Identifier" | "CallExpression".
Something goes really wrong when I try to use node.type as an index, maybe because its type doesn't perform well if used as an index to access the Visitor type.
🙂 Expected behavior
typeof node.type inferred as K because it is simpler to interact with and doesn't give problems if used as an index.
Bug Report
🔎 Search Terms
reduction, generic, union, intersection
🕗 Version & Regression Information
This bug is also the 'Nightly' version. Versions prior to
4.6.2give even more errors.⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
typeof node.typeis inferred as(K & "NumericLiteral") | (K & "StringLiteral") | (K & "Identifier") | (K & "CallExpression")that it is equal toKitself considering thatK extends "NumericLiteral" | "StringLiteral" | "Identifier" | "CallExpression".Something goes really wrong when I try to use
node.typeas an index, maybe because its type doesn't perform well if used as an index to access theVisitortype.🙂 Expected behavior
typeof node.typeinferred asKbecause it is simpler to interact with and doesn't give problems if used as an index.