Search Terms
Array lookup
Array lookup undefined
Array indexing undefined
Suggestion
Please forgive my TypeScript terminology.
I am proposing for the compiler to assume that array lookup can return undefined inside conditional expressions ONLY.
I am NOT proposing for all array lookup to return T | undefined (#11122)
Use Cases
This helps to catch subtle, hard to spot bugs.
Examples
constsetItem=(value: Item|undefined)=>{item=value};// This a bug, setItem shouldn't accept null, TS didn't catch it.setItem(response.data.items[0]||null)Checklist
My suggestion meets these guidelines:
Search Terms
Array lookup
Array lookup undefined
Array indexing undefined
Suggestion
Please forgive my TypeScript terminology.
I am proposing for the compiler to assume that array lookup can return undefined inside conditional expressions ONLY.
I am NOT proposing for all array lookup to return
T | undefined(#11122)Use Cases
This helps to catch subtle, hard to spot bugs.
Examples
Checklist
My suggestion meets these guidelines: