- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.1k
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:
Version 1.9.0-dev.20160617-1.0
Code
interface Foo {
  prop?: string
  [key: string]: string
}{
  "compilerOptions": {
    "strictNullChecks": true
  }
}Expected behavior: No error. Wouldn't the fact that it's an index signature implicitly signal that it could also be undefined?
Actual behavior:
index.ts(2,3): error TS2411: Property 'prop' of type 'string | undefined' is not assignable to string index type 'string'.
Edit: On the other side of the coin with this usage:
interface Foo {
  [key: string]: string
}
const foo: Foo = {}
const bar = foo['test']Should bar be type of string | undefined?
Strate, felixfbecker, DanTup, Elephant-Vessel, nomcopter and 10 more
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