-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: 2.1.4
Code
interface Data {
items: number[]
}
export interface DataCollection {
[i: string]: Data
}
const collection: DataCollection = {}
const datum: Data = collection['not-present'] || 'horse' // this line should fail the type-check
datum.items = [1, 2, 3];Expected behavior:
A compile time error.
I would expect something like:
error TS2322: Type '"horse"' is not assignable to type 'Data'.
Actual behavior:
A runtime error:
Uncaught TypeError: Cannot create property 'items' on string 'horse'
Strate
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug