Skip to content

TS 4.2 beta preserves "keyof" expressions in type displayΒ #42322

Closed
@danvk

Description

@danvk

Bug Report

πŸ”Ž Search Terms

  • keyof 4.2

πŸ•— Version & Regression Information

$ tsc --version
Version 4.2.0-dev
  • This changed between versions 4.1.3 and 4.2.0-beta

⏯ Playground Link

playground

πŸ’» Code

interface Point {
  x: number;
  y: number;
}
type Axes = keyof Point;

Mouse over Axes.

πŸ™ Actual behavior

Displays keyof Point

πŸ™‚ Expected behavior

Displays "x" | "y".

I assume this is the result of #42284, but this display seems much less informative than what we used to have:

Having used keyof in the past, I know that keyof Point is the same as "x" | "y". But displaying its type as keyof Point isn't very informative if you don't know that. I worry that this will make it much harder for new TypeScript users to understand how keyof works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions