Skip to content

"keyof" infers type incorrectly when it is applied to interface that extends Record<string, any>Β #55706

Closed as not planned
@nicky1038

Description

@nicky1038

πŸ”Ž Search Terms

keyof interface extends record number

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Link

πŸ’» Code

interface EmptyInterface {};
type StringRecord = Record<string, string>;
interface Interface extends StringRecord {};

type EIFKey = keyof EmptyInterface // never
type SRKey = keyof StringRecord // string
type IFKey = keyof Interface // number | string, why not string?

πŸ™ Actual behavior

IFKey is number | string

πŸ™‚ Expected behavior

IFKey should be string

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions