microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.21k stars 12.51k forks source link

`satisfies` is shown on go-to-implementation #60551

Open ulugbekna opened 3 days ago

ulugbekna commented 3 days ago

🔍 Search Terms

"satisfies", "go-to-implementation", "go to implementation", "implementation"

✅ Viability Checklist

⭐ Suggestion

Currently, "go to implementation" on a type functionality for typescript code in VSCode will go to places where an object of this type is created. This works

interface Person {
    name: string;
}

function f() {
    const john: Person = { name: 'John' }; // both this type annotation and `as` syntaxes show these objects as implementations of `Person` 

    const andrew = { name: 'Andrew' } as Person;

        const tyler = { name: 'Tyler' } satisfies Person; // this is not shown as an implementation of `Person` 
}

Image

📃 Motivating Example

Go to implementation is a very easy way to see who produces objects of a particular type.

satisfies marking a type to adhere to a particular type without creating a new variable using type annotation syntax.

💻 Use Cases

  1. What do you want to use this for? Identify implementations of a type.

  2. What shortcomings exist with current approaches? None I can think of.

  3. What workarounds are you using in the meantime? Going to references and reading code.