Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Interface 'MyInterface<T>' incorrectly extends interface - for named tuple type that has '...rest' param #51751

Copy link
Copy link
@pmunin

Description

@pmunin
Issue body actions

Bug Report

Error happens only when:

  • MyInterface extends type alias which represents named array tuple
  • MyInterface is generic
  • MyType is NAMED tuple
  • MyType has ...rest

🔎 Search Terms

type alias, named tuple, interface

🕗 Version & Regression Information

Typescript v4.9.3

⏯ Playground Link

Playground link with relevant code

💻 Code

The following code throws that error:

type MyType = [
  name1:string,
  name2: number,
  ...rest:any[]
]

interface MyInterface<T> extends MyType {
}

// "Interface 'MyInterface<T>' incorrectly extends interface '[name1: string, name2: number, ...rest: any[]]'.

All of the following below works fine:

type MyType = [
  name1:string,
  name2: number,
  ...rest:any[]
]

interface MyInterface extends MyType { //MyInterface is not generic => works
}

// ----------- OR -------------

type MyType = [ // MyType does not have ...rest => works fine
  name1:string,
  name2: number
]

interface MyInterface<T> extends MyType {
}

// ------------ OR ------------
type MyType = [ // MyType typle elements are not named => works fine
  string,
  number,
  ...any[]
]

interface MyInterface<T> extends MyType {
}

🙁 Actual behavior

TSC throws error:

Interface 'MyInterface<T>' incorrectly extends interface '[name1: string, name2: number, ...rest: any[]]'.

🙂 Expected behavior

Successfull compilation

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptA bug in TypeScriptDomain: Something ElseFallback label when we just can't figure anything else outFallback label when we just can't figure anything else outHelp WantedYou can do thisYou can do this

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.