TS regression: Narrowing of MathNodes by type
Open
bug
help wanted
typescript
- Dominant language
- JavaScript
- Stars
- 15.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Prior to v11.3 (not sure how far back, but certainly at least 10), `MathNode` would be narrowed based on its `type` property:
```ts
const doStuffWithMathNode(node: MathNode) => {
if (node.type === 'FunctionAssignmentNode) {
// now TS knows that node is a FunctionAssignmentNode and lets you access associated props
// like node.params
}
// back to being a wider MathNode
}
```
**To Reproduce**
- working in v11.2 https://codesandbox.io/s/typescript-playground-export-forked-wnelgb?file=/index.ts
- erroring in v11.3 https://codesandbox.io/s/typescript-playground-export-forked-ke8srr?file=/index.ts
Contributor guide
Assessment
This issue has not been assessed yet.