- Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms: Object undefined
Code turn strictNullChecks on
// A *self-contained* demonstration of the problem follows... // Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc. type EventType = 'click' | 'dblclick' const handlerMap: { [P in EventType]?: any[] } = {} function addHandler<P extends EventType>(evType: P) { const handlerList = handlerMap[evType] || [] handlerList.push({}) // Error here: Object is possibly 'undefined' handlerMap[evType] = handlerList }Expected behavior: No Error
Actual behavior: Shows Error
Related Issues:
matthargett, thorn0, KrzysztofKarol, marcj, Ionaru and 18 moremunepom, collin5, KrzysztofKarol, hsuehic, itmayziii and 1 more
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created