Skip to content

assignabiltity between interfaces and types #14736

@wclr

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
}

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy