babel-plugin-jsdoc-closure
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "babel-plugin-jsdoc-closure", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Transpiles JSDoc types from namepaths to types for Closure Compiler", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,3 +9,3 @@ # babel-plugin-jsdoc-closure | ||
npm install babel-cli babel-plugin-jsdoc-Closure | ||
npm install babel-cli babel-plugin-jsdoc-closure | ||
@@ -77,1 +77,41 @@ ### Configuration | ||
node build.js | ||
## What the plugin does | ||
Closure Compiler does not allow JSDoc's [namepaths](http://usejsdoc.org/about-namepaths.html) with [module identifiers](http://usejsdoc.org/howto-commonjs-modules.html#module-identifiers) as types. Instead, with `module_resolution: 'NODE'`, it recognizes types that are imported from other files. Let's say you have a file `foo/Bar.js` with the following: | ||
```js | ||
/** @module foo/Bar */ | ||
/** | ||
* @constructor | ||
* @param {string} name Name. | ||
*/ | ||
const Bar = function(name) { | ||
this.name = name; | ||
}; | ||
export default Person; | ||
``` | ||
Then you can use the `Person` type in another module with | ||
```js | ||
/** | ||
* @param {module:foo/Bar} bar Bar. | ||
*/ | ||
function foo(bar) {} | ||
``` | ||
This is fine for JSDoc, and this plugin transforms it to something like | ||
```js | ||
/** | ||
* @param {foo$Bar} bar Bar. | ||
*/ | ||
function foo(bar) {} | ||
const foo$Bar = require('./foo/Bar'); | ||
``` | ||
With this, the type definition is recognized by Closure Compiler. | ||
**Note**: To avoid the need for source maps, line numbers are retained by this plugin. This is the reason why the `require()` assignments are added at the bottom of each file. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12114
116