Bug Report
π Search Terms
array index element undefined
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about type of element selected from (potentially) empty array
β― Playground Link
Playground link with relevant code
π» Code
constary: string[]=[];constfirstElement=ary[0];// `firstElement`'s type is `string` while it should be `string | undefined`// or even better `undefined` since that can be deduced from the line above.
π Actual behavior
firstElement is of type string.
π Expected behavior
firstElement should be of type string | undefined or undefined if that can be deduced.
Bug Report
π Search Terms
array index element undefined
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
firstElementis of typestring.π Expected behavior
firstElementshould be of typestring | undefinedorundefinedif that can be deduced.