Unions seem to sidestep --noUncheckedIndexedAccess
and lose the possibility of undefined
#61225
Labels
Milestone
π Search Terms
noUncheckedIndexedAccess, union, undefined
π Version & Regression Information
--noUncheckedIndexedAccess
β― Playground Link
Playground link
π» Code
π Actual behavior
The type of
wha
isstring | number
, completely ignoring the possibility that it might beundefined
, even though--noUncheckedIndexedAccess
is enabled. Looks like unions of types with index signatures and known keys lose the--noUncheckedIndexedAccess
behavior.π Expected behavior
wha
should be of typestring | number | undefined
, just likehmm
, since indexed access into a union should look like a union of indexed accesses.Additional information about the issue
This is related to #50474. Itβs also related to #47531, which had specifically to do with
never[]
and so the focus was on avoidingnever[]
as opposed to investigating what happened to the indexed access. ( #47531 (comment) )Ran into this when looking at a Stack Overflow question
The text was updated successfully, but these errors were encountered: