Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlowNode graph of switch-case broken on TS 5.5.x #158

Open
jfet97 opened this issue Sep 4, 2024 · 0 comments · May be fixed by #159
Open

FlowNode graph of switch-case broken on TS 5.5.x #158

jfet97 opened this issue Sep 4, 2024 · 0 comments · May be fixed by #159

Comments

@jfet97
Copy link
Contributor

jfet97 commented Sep 4, 2024

This is the code that causes problems:

type Payload =
| { _tag: "key", secret: string }
| { _tag: "cart", cart: [] }
| { _tag: "person", person: unknown }

declare const p: Payload

switch(p._tag) {
    case "key": {
        p.secret
        break
    }
    case "cart": {
        p.cart
        break
    }
    case "person": {
        p.person
        break
    }
    default: {
        p // never
    }
}

If you try to render the FlowNode(s) graph on p from within one case, you'll get the error $A.node.getText is not a function. This is due to changes on the data structures of flow nodes, after their attempt to increase monomorphization. Before TS 5.5 we got fn.switchStatement, now we have fn.node.switchStatement, but fn.node itself doesn't have the getText capability.

Will follow a small PR with a simple fix.

jfet97 added a commit to jfet97/ts-ast-viewer that referenced this issue Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant