Tern & JSDoc support - angelozerr/tern.java GitHub Wiki
tern.js provides the doc_comment tern plugin which gives a support for JSDoc.
After installing and converting your project as Tern Project, go at Tern project property, go at Tern project property, click on Tern / Modules item and select the JSDoc Support tern plugin :
After that, tern can use the JSDoc tags. Here a sample which assign the test
variable as String
type by using @type :
Options
The JSDoc support can be configured with several options.
strong option
The strong
option can be set to true to assign a higher-than-default weight to the types it finds in comments, and thus overrides inferred types
.
Takes a sample. If you assign the test
variable with a number value, test
has 2 types :
String
coming from the JSDoc.Number
coming from the written code assignment.
If you wish to ignore the type coming from the written code assignment and just use the type coming from the JSDoc, you must check the strong
option :
After that, your test
variable will have just types coming from JSDoc (the toExponential
method doesn't appear in the completion popup):
Validation
To validate your JavaScript files with JSDoc annotations, you must :
- Check Lint.
- Check JSDoc support.
- Check strong option.
After that, the Lint validator is able to validate your JavaScript files by using JSDoc annotations :
Assignment validation
Here a sample with assignment type error :
Function call validation
Here a sample with function parameter type error: