Skip to content

Type and interface have different behavior in index signature extends checking. #57810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ruojianll opened this issue Mar 17, 2024 · 2 comments
Closed

Comments

@ruojianll
Copy link

πŸ”Ž Search Terms

"extends", "type and interface"

πŸ•— Version & Regression Information

version all

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.4.2#code/C4TwDgpgBAKu0F4oG8BQUNQIYC4oDsBXAWwCMIAnVAX1VQEt9hKAzLAY2gEknWPo0mbHiJlKNOqEhQAglCRxpEAB7N8AEwDOUAEoR2AewrqAPJuAVGAcwA0BEuQoA+KAH4oFwtDxsANpugAekDPCFQpaAAheSgeZgo2TigVNS1dfSNTc0t8W3sxZzcPCi8oHyx-IMC-ANQgA

πŸ’» Code

type Type = {
    a: number
}

interface Interface {
    a: number
}

type A = Type extends Record<string, number> ? true : false //true
type B = Interface extends Record<string, number> ? true : false //false

πŸ™ Actual behavior

type A is true
type B is false

πŸ™‚ Expected behavior

both true or false

Additional information about the issue

No response

@ruojianll
Copy link
Author

I can't find any document about the difference about this.

@MartinJohns
Copy link
Contributor

Duplicate of #42825. See also #15300 (comment).

Used search terms: interface type record in:title

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants