Skip to content

Key remapping breaks definition navigation for mapped type properties #47813

@ayatkevich

Description

@ayatkevich

Bug Report

When using mapped type with key remapping, definitions for the properties of mapped types are no longer discoverable. Though, references are still in there.

🔎 Search Terms

mapped types, key remapping, language server, editor hints

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about mapped types

⏯ Playground Link

Playground link with relevant code

💻 Code

const object = {
    a: 1,    // ✅ can go to definition/references, can rename
    b: 2,    // ✅ can go to definition/references, can rename
    c: 'ok', // ✅ no references, can rename
};
/** ✅ rename of {@link object.a} and {@link object.b} will correctly rename all the references as well */

const remapByKey: {
    [P in keyof typeof object as P extends 'c' ? never : P]: 0;
} = { a: 0, b: 0 };

remapByKey.a; // ❌ can't go to definition, can't rename, ✅ yet highlights definition
remapByKey.b; // ❌ can't go to definition, can't rename, ✅ yet highlights definition
remapByKey.c; // ✅ errors as expected

const remapByValue: {
    [P in keyof typeof object as typeof object[P] extends string ? never : P]: 0;
} = { a: 0, b: 0 };

remapByValue.a; // ❌ can't go to definition, can't rename, ✅ yet highlights definition
remapByValue.b; // ❌ can't go to definition, can't rename, ✅ yet highlights definition
remapByValue.c; // ✅ errors as expected

🙁 Actual behavior

image

🙂 Expected behavior

Capability to navigate to definition of remapped property.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions