IntelliJ TypeScript Structural Search

146 Views Asked by At

Is it possible to define a structural search in IntelliJ to warn about the use of the native JavaScript String class instead of the Typescript string type? The typescript documentation recommends that you never use the native JavaScript types (see here).

Our team is going back and forth between Kotlin and Typescript code so it is easy to inadvertently use String. I would want to detect this in places like function parameters, variables, and as fields in classes.

For some more clarity on what I am interested in doing:

class MyTypescriptClass {
  myField: String;         //Inspection would generate warning on this line.
  anotherField: string;    //Inspection would not generate warning on this line.

  fun1(param: String) {}   //Inspection would generate warning on this line.

  fun2(param: string) {}   //Inspection would not generate warning on this line.
}
1

There are 1 best solutions below

1
Bas Leijdekkers On BEST ANSWER

Creating the short template String should do it. Make sure the Match Case checkbox is checked. Structural Search Dialog