Skip to content

Goto definition after field exclusion should go to prop signature #23216

Open

Description

@cevek

TypeScript Version: master

Code

type OmitKeys<A, B> = {[P in Exclude<keyof A, B>]: A[P]}
interface Foo {
    a: number;
    b: string;
    c: boolean;
}
var c: OmitKeys<Foo, 'c'>;
c.a // goto definition doesn't work

Expected behavior:
Goto definition on c.a takes me to the Foo.a property

Actual behavior:
Goto definition doesn't work

Activity

  1. mhegazy commented on Apr 6, 2018

    @mhegazy
    Contributor

    At this point the compiler really can not track the key back to its declaration. Exclude<keyof A, B> just returns a list of literal types, then the map type generates a new type with properties of the same name..

  2. cevek commented on Apr 6, 2018

    @cevek
    Author

    I know that is not possible for everything, but maybe you can track some information where from came this symbol if it possible?

    In the example above we definitely know that a symbol came from keyof Foo with defined position in the code.

  3. cevek commented on Apr 6, 2018

    @cevek
    Author

    Conditional types is very powerful feature, but with this behaviour without go to definition you also cannot rename refactor

  4. mhegazy commented on Apr 6, 2018

    @mhegazy
    Contributor

    The probable is once it goes through literal types, context is lost.. We would be happy to discuss a proposal on how this can be added.

  5. cevek commented on Apr 6, 2018

    @cevek
    Author

    Andy (Andrewkraft) (@Andy-MS) Here is corner case example where it doesn't work as we expected,
    but anyway your solution is good and simple

    interface I { a: number; }
    interface X { a: string; }
    declare const mapped: { [K in keyof X]: I[K] };
    mapped.a;
    
  6. typescript-bot commented on Apr 21, 2018

    @typescript-bot
    Contributor

    Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

  7. sandersn commented on Apr 23, 2018

    @sandersn
    Member

    Andy (Andrewkraft) (@Andy-MS) It's a matter of setting up a trail of synthetic symbols with pointers back to their original symbol. I don't know if getIndexAccessType do this when it is working on 0-order properties. If not, that's the place that would need to change.

  8. ghost removed
    Design LimitationConstraints of the existing architecture prevent this from being fixed
    on Apr 23, 2018
  9. ghost added
    Needs InvestigationThis issue needs a team member to investigate its status.
    on Apr 23, 2018
  10. ghost reopened this on Apr 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: LS: Symbol NavigationRelates to go-to-definition, find-all-references, highlighting/occurrences.Experience EnhancementNoncontroversial enhancementsSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions