rx153
rx153

Reputation: 73

Intellij TypeScript Variable Name Autocomplete

In Java, you usually type the type when you declare a variable or field.

eg:

public SomeDataType someDataType = new SomeDataType(123)

when you start typing Som.. the intellij autocomplete will probably start suggesting SomeDataType and you can hit tab to apply it.

When you've declared that the type is SomeDataType, when you start writing the name som.. it will suggest someDataType for the variable name.

In Java there is an obvious flow. what you actually type is

pu[tab]Som[tab]som[tab]

in TypeScript, you do it the other way round

public someDataType: SomeDataType;

is there something similar for TypeScript in intellij? currently afaik, to get the same behavior you have write

pu[tab]:Som[tab][crtl + <-][ctrl + <-]som[tab][ctrl + ->][ctrl + ->]

which is extremely awkward and flowbreaking. it's even worse when your linter expects a lot of spaces.

what's the real trick here?

Upvotes: 7

Views: 473

Answers (1)

lena
lena

Reputation: 93728

With JavaScript/Suggest variable names enabled in Settings | Editor | General | Code Completion, IDEA suggests names based on project types for new variables during their declaration:

enter image description here

Upvotes: 4

Related Questions