Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-jsdoc-closure

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-jsdoc-closure - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc