Skip to content

assignabiltity between interfaces and types #14736

Description

@wclr

TypeScript Version: 2.2.1 / nightly (2.3.0)

I believe my issue can be narrowed down:

export interface Params {
  [name: string]: string
}

function doSmth(params: Params) { }

interface MyParams {
  prop: string
}

let myParams: MyParams = { prop: 'X' }

let params: Params = myParams // NOT OK

Actual behavior:

Type 'MyParams' is not assignable to type 'Params'.
  Index signature is missing in type 'MyParams'.

if to replace interface with type there is no error:

type MyParams = {
  prop: string
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions