Bring typeof switch closer inline with if#27680
Conversation
src/compiler/checker.ts
Outdated
| return caseType.flags & TypeFlags.Never ? defaultType : getUnionType([caseType, defaultType]); | ||
| } | ||
|
|
||
| function getTypeFromName(type: Type, text: string) { |
There was a problem hiding this comment.
Would prefer a more descriptive name like getNarrowedTypeByTypeofResult
There was a problem hiding this comment.
Went with getImpliedTypeFromTypeofCase to be consistent with terminology used in the documentation of narrowBySwitchOnTypeOf.
|
@typescript-bot test this |
|
Heya @RyanCavanaugh, I've started to run the extended test suite on this PR at b12ed40. You can monitor the build here. It should now contribute to this PR's status checks. |
- Narrow unknown - Narrow union members (in addition to filtering)
b12ed40 to
b63b40b
Compare
|
@typescript-bot test this but again since it was edited (it passed before, so it should be fine, but just in case~) |
|
Heya @weswigham, I've started to run the extended test suite on this PR at b63b40b. You can monitor the build here. It should now contribute to this PR's status checks. |
This PR brings
switchnarrowing withtypeofcloser inline withif, which was recently updated in two keys ways:Function, the latterobject | null.Fixes #27180
Fixes #27335
Adds tests for #27181