Closed
Description
Suggestion
π Search Terms
isIntersectionType type predicate internal source code
β Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
β Suggestion
Spinning #49727 (comment) into its own issue: there are a lot of type assertions internal to TypeScript that seem to predate type predicates.
It'd be nice to test out this this kind of change to the internal TypeScript source code:
- if (type.flags & TypeFlags.Intersection) {
+ if (isIntersectionType(type)) {
- for (const subType of (type as IntersectionType).types) {
+ for (const subType of type.types) {
π Motivating Example
n/a
π» Use Cases
See changes in #49727.
Edit: ...and see #50010 for a draft PR.
Metadata
Metadata
Assignees
Labels
No labels