lang | title | keywords | sidebar | permalink |
---|---|---|---|---|
en |
Developing with WebStorm |
LoopBack 4.0, LoopBack 4 |
lb4_sidebar |
/doc/en/lb4/Developing-with-webstorm.html |
For contributors using WebStorm as their preferred development environment, we recommend the following extensions to be installed:
- Prettier - Code Formatter for automatic formatting of source files on save.
We also recommend our contributors to enable
TSLint in WebStorm
to highlight and auto-fix linting problems directly in the editor. Make sure you
are using the TSLint package from loopback-next
loopback-next/packages/build/node_modules/tslint
.
Please note that you should at least use WebStorm 2018.3
to avoid
an indexing issue.
-
Open any existing TypeScript file, e.g.
packages/src/index.ts
-
Add a small bit of code to break TypeScript's type checks, for example:
const foo: number = 'bar';
-
Verify that WebStorm editor has marked
foo
with a red underscore. Hover overfoo
and check the problem message. It should start withTS
prefix followed by a message, e.g.TS2322: Type '"bar"' is not assignable to type 'number'.
-
Check WebStorm Typescript Window. There should be an entry showing the same error. When you click on the entry, it should jump on the problematic line.
Verify that "Go to declaration" works across package boundaries. Find a place
where we are calling @inject
in authentication
package, press Ctrl+B
to go
to the declaration of inject
. WebStorm should jump to the .ts
file in src
(as opposed to jumping to a .d.ts
file in dist
)
It seems that refactorings like "rename" with (Maj+F6
) will not change the
renamed entity across packages.
-
Open any existing TypeScript file, e.g.
packages/src/index.ts
-
Verify that TSLint is not reporting any warnings : An example of a warning we want to avoid:
Warning: The 'no-unused-variable' rule requires type information.
-
Introduce two kinds linting problems - one that does and another that does not require type information to be detected. For example, you can add the following line at the end of the opened
index.ts
:const foo: any = 'bar';
-
Verify that WebStorm editor has marked
any
with a red underscore. Hover overany
and check the problem message. It should mentionno-any
rule, e.g.TSLint: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type. (no-any)