Git Product home page Git Product logo

jsdoc-plugin-intersection's Introduction

NPM

JSDoc Intersection Plugin

Converts TypeScript intersection types (joined with an "&") to a JSDoc type union "|" allowing the file to be processed downstream. This allows you to use the amperstand "&" in your code.

Specifically, this creates a compatibility between Visual Studio Code's TypeScript documentation and JSDoc, as Visual Studio Code's parser uses amperstands for type unions, and JSDoc uses pipes.

You may find my other JSDoc plugins interesting:

Solving the Problem

Using JSDoc in Visual Studio code with their TypeScript-oriented intersection:

/**
 * This is my favorite function!
 * @param {SomeClass & {abc: 123}}
 */

Results in...

ERROR: Unable to parse a tag's type expression for source file ...: Invalid type expression "SomeClass & {abc: 123}": Expected "|" but "&" found.

Uh oh! JSDoc doesn't like this. It's a TypeScript thing and won't be supported.

Resolution

Thankfully, this JSDoc plugin solves the problem by converting your intersecting types to compatible JSDoc union types. There's no need to hack your code together with strange @typedefs.

Just Install

yarn add jsdoc-plugin-intersection --dev

or

npm install jsdoc-plugin-intersection --save-dev

Update your JSDoc configuration, and include the plugin:

...
    "plugins": [
        "jsdoc-plugin-intersection"
    ],
...

That's all!

jsdoc-plugin-intersection's People

Contributors

brunohafonso95 avatar chriseaton avatar siegcollado avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jsdoc-plugin-intersection's Issues

relevance in 2021 and how to use this plugin with vscode

I have the following questions:
Q1. Is this plugin still relevant in 2021, or there some other solution recommended?
Q2. How exactly does one use this plugin with Vs Code? Specifically, where is the JSDOC configuration file located? If the configuration file needs to be created, what name should it have, can a template be provided, and how does this configuration file get read by VsCode - is there some other configuration needed to point to this JSDoc config file?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.