Make VSCode autocomplete React props type as well as name?

Viewed 614

I'm trying to migrate from WebStorm to VSCode. VSCode seems to autocomplete my prop names fine (I'm also using TypeScript), but one thing that I like about WebStorm is it not only autocompletes the prop name, it also adds the = and either "" or {} (it uses TS to know what prop type it is and adds the appropriate thing).

So, for example, if I have a Person component that has name as a string, in WebStorm I can type <Person and hit tab when it auto-suggests "name", which will automatically have <Person name="" with my cursor in-between the quotes. Similarly, if age is a number it would have <Person age={} with my cursor between {}.

Does VSCode have a similar setting that I can set?

1 Answers

Check if this is similar to issue 33641 which mentioned:

In the corner it said it was running Typescript 2.0.0.
I assumed that it would run whichever version of typescript my project declared in the package.json file.

Clicking on that in the corner brought me to the page which explained that the typescript.tsdk user setting can be used to point to a specific typescript installation.
After switching this setting and restarting VSCode, it said 2.4.2 in the corner and suddenly completion of React props started to work correctly.

Related