Fork me on GitHub

What is jsdoctypeparser?

jsdoctypeparser is a JSDoc type expression parser module. This module can parse:

JSDoc style
foo.bar, String[], module:foo/bar
Closure Compiler style
Array.<string>, function(arg1, arg2): ret
TypeScript types (some)
[string, string], import("./package").Type
Complex types
Array.<Array.<string>>, { length: number }

This module is available on github or npm.


Let's try!

/** @type { } */

Options

Complete parsing!

Syntax Error


          

Any questions?

Please file an issue or join us on our Discord chat for jsdoc.

Result

Parsing

const {parse} = require('jsdoctypeparser');
const result = parse(yourTypeExpression);
console.log(result);

The console output is:


        

Publishing

const {publish} = require('jsdoctypeparser');
console.log(publish(result));