4.0.0-dev • Published 5 years ago

jsdoc-import-typedef v4.0.0-dev

Weekly downloads
66
License
Apache-2.0
Repository
github
Last release
5 years ago

jsdoc-import-typedef

This is a fork of jsdoc to deal with typescript type check import way - https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#import-types

Motivation

There are some issues in jsdoc related to this problem and a feature is open here: https://github.com/jsdoc/jsdoc/issues/1645. But the feature will be very complex and maybe can take some time to be done. And I need this fix asap.

Cause

jsdoc uses catharsis to parse the expressions and catharsis.parse doesn't accept the typescript import expression (ex: @param p { import("./a").Pet }).

This raises Invalid type expression like seem here https://github.com/hegemonic/catharsis/blob/master/bin/parse.js#L48

Instead of patch catharsis, I apply the fix in jsdoc, using a regexp to remove this pattern before the string is parsed by catharsis.parse.

In this case, @param p { import("./a").Pet } will be interpreted like @param p { Pet } in jsdoc.

Works great if you are using Typescript to type check your jsdoc - (https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html) and is compatible with all jsdoc templates.

Installation

npm install jsdoc-import-typedef

Usage

This is a patched jsdoc and all its usage remains the same (https://github.com/jsdoc/jsdoc#installation-and-usage).

For more information

License

JSDoc is copyright (c) 2011-present Michael Mathews micmath@gmail.com and the contributors to JSDoc.

JSDoc is free software, licensed under the Apache License, Version 2.0. See the LICENSE file for more details.