Skip to content

mapped type with remapped keys unexpectedly widens typeΒ #57265

@rotu

Description

@rotu

πŸ”Ž Search Terms

keyof, string, record

πŸ•— Version & Regression Information

  • This changed between versions 4.4.4 and 4.5.5

⏯ Playground Link

No response

πŸ’» Code

type R = { [K in keyof Record<string,unknown> as K]: unknown; };
//   ^?
type K = keyof R;
//   ^?
let s:string = "a" as K

Workbench Repro

πŸ™ Actual behavior

keyof R is string | number.

πŸ™‚ Expected behavior

keyof R is string.

Additional information about the issue

No response

Metadata

Metadata

Assignees

Labels

Has ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy