Code Monkey home page Code Monkey logo

Comments (12)

NewFuture avatar NewFuture commented on June 28, 2024 2

sure, I create an issue in dts-dom RyanCavanaugh/dts-dom#27

from tsd-jsdoc.

NewFuture avatar NewFuture commented on June 28, 2024 2

fixed

from tsd-jsdoc.

NewFuture avatar NewFuture commented on June 28, 2024 1

@englercj
i think it is a bug of dts-dom.
https://github.com/RyanCavanaugh/dts-dom/blob/master/lib/index.ts#L672-L674

here it doesn't add ? for the method of interface

from tsd-jsdoc.

englercj avatar englercj commented on June 28, 2024

The jsdoc comment it output verbatim from what jsdoc gives us (we indent it, but that's it). If the comment is wrong in the output, then jsdoc isn't parsing it the way you think it is. I'm pretty sure that is CC syntax not JSDoc (strictly speaking), maybe that is the issue?

That being said, there isn't really a "nullable" concept in Typescript so I'm not sure how I would express that concept anyway (outside the comment).

from tsd-jsdoc.

VinceOPS avatar VinceOPS commented on June 28, 2024

Hi @englercj

Thanks for your quick answer.
You're right about nullable parameter for Typescript.

The syntax comes from usejsdoc.org:

Nullable type | A number or null.
{?number}
This indicates that the type is either the specified type, or null.

But you're right, what I'd rather use is optional parameters, which look like:

/**
 * @param {number} [eventValue] (optional) Value attached to the target event.
 */

Optional parameter | An optional parameter named foo.
@param {number} [foo]
Indicates that the parameter is optional. When using JSDoc's syntax for optional parameters, you can also indicate the value that will be used if a parameter is omitted.

Which should be, in typescript:

function logEvent(eventValue?: number) { }

According to the TS doc @ "Optional and Default Parameters"

from tsd-jsdoc.

englercj avatar englercj commented on June 28, 2024

Optional parameters (and interface members) should already work correctly now, is that working for you?

As for nullable, not sure why your comment is rewritten but also pretty sure it isn't a bug in this repo.

from tsd-jsdoc.

NewFuture avatar NewFuture commented on June 28, 2024

Hi @englercj, thanks for your great tools.

but, it's still not working for me (2.0.0-beta.3)

JavaScript

/**
 * @interface i
 */
var i = {}
/**
 * @method i.f
 * @param {number} [optional] - optional pararms
 */
i.f = function (optional) { }

.d.ts

/**
 * @interface i
 */
declare interface i {
    /**
     * @method i.f
     * @param {number} [optional] - optional pararms
     */
    f(optional: number): void; // should be f(optional?: number)
}

When commentting i as class, it will parse correctly.
is there any bug?

from tsd-jsdoc.

VinceOPS avatar VinceOPS commented on June 28, 2024

@englercj Sorry for the delay - The "optional parameter" syntax is not working.
Just like @NewFuture , I am using @interface (appropriate).

from tsd-jsdoc.

englercj avatar englercj commented on June 28, 2024

Hmm, I'll have to look into that. If it is working in class, but not interface then it is likely a bug. Strangely though this lib doesn't treat functions in interfaces and classes differently. It is possible jsdoc has another parsing issue.

from tsd-jsdoc.

NewFuture avatar NewFuture commented on June 28, 2024

I built the js file to html by the JSDOC,.
in the result, the optional will be marked as opt correctly.

Maybe jsdoc has different behaviors for the methods of class and inteface.

from tsd-jsdoc.

englercj avatar englercj commented on June 28, 2024

Ah, great catch! That certainly seems like the issue. Thanks for tracking this down.

from tsd-jsdoc.

VinceOPS avatar VinceOPS commented on June 28, 2024

(previous comment removed)

Thanks for handling this with us @NewFuture ! Thanks again for your work @englercj

from tsd-jsdoc.

Related Issues (20)

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.