-
Notifications
You must be signed in to change notification settings - Fork 52
Tern & JSDoc support
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 :
The JSDoc support can be configured with several options.
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):
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 :
Here a sample with assignment type error :
Here a sample with function parameter type error:
- Tern IDE
- Tern Toolings
-
Tern Modules
- AngularJS
- AlloyUI
- Browser
- Bootstrap
- CKEditor
- CordovaJS
- Dojo Toolkit
- ECMAScript
- ExtJS
- Game
- jQuery
- JSDoc Support
- Liferay
- Meteor
- Node.js
- Qooxdoo
- snabbt.js
- RequireJS
- Tabris.js
- three.js
- Titanium
- YUI Library
- Completion
- Linter (Validator)
- Tests
- JavaScript Build
- New and Noteworthy