Skip to content
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

Interface doesn't extends Record<string, unknown> #54391

Closed
erwanvivien opened this issue May 25, 2023 · 2 comments
Closed

Interface doesn't extends Record<string, unknown> #54391

erwanvivien opened this issue May 25, 2023 · 2 comments

Comments

@erwanvivien
Copy link

Bug Report

Simple interface doesn't extends Record<string, unknown>

We can't use extends object because it's for any JS object, it's not good

🔎 Search Terms

Interface extends Record unknown

🕗 Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries

⏯ Playground Link

https://www.typescriptlang.org/play?#code/C4TwDgpgBAsg9gNwgFXNAvFA3lAHgLigDsBXAWwCMIAnAGihENMpqgF8AoASyOBoDMAhgGNo8JAEleAkdBwFi5KnQZMlrTh2FwiAZ2BQuugBoBNKJgAUgwgCUI26gBMAPPuo8A5vRJEA1kRwAO5EAHwAlISChrrYeGosKoyKiewWodgcUFDUEMAk1ERQwNQkEByaADZ5xYTiKGgWcQoADPTJLewc1QZcdYgQUnzUQqJN8oRtqlCdmkZmlsDh3CamllzLQA

💻 Code

type MoveType = { x: number, y: number }
interface MoveInterface { x: number, y: number }

const isXY = (a: Record<string, unknown>): a is { x: number, y: number } => {
  return true
}

let t: MoveType = { x: 0, y: 0 }
let i: MoveInterface = { x: 0, y: 0 }

isXY(t)
isXY(i)

🙁 Actual behavior

We can use isXY for the type, not for the interface

🙂 Expected behavior

Can use isXY(i)

@MartinJohns
Copy link
Contributor

Duplicate of #42825. This is working as intended.

@erwanvivien
Copy link
Author

Thanks @MartinJohns I tried to check if this error was known and didn't found this issue, I'm closing this one

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