Skip to content

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

@erwanvivien

Description

@erwanvivien

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions