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
It would be better if we allow union types to work on control flow analysis
π Motivating Example
typeShape=|{kind: "circle",radius: number}|{kind: "square"|'rectangle',sideLength: number};functionarea(shape: Shape): number{if(shape.kind==="square"||shape.kind==="rectangle"){// We know we have a square/rectangle here!returnshape.sideLength**2;}else{// We know we 're left with a circle here!// But TypeScript failed to recognize itreturnMath.PI*shape.radius**2;}}
π» Use Cases
The text was updated successfully, but these errors were encountered:
Suggestion
π Search Terms
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
It would be better if we allow union types to work on control flow analysis
π Motivating Example
π» Use Cases
The text was updated successfully, but these errors were encountered: