Comments (12)
sure, I create an issue in dts-dom RyanCavanaugh/dts-dom#27
from tsd-jsdoc.
fixed
from tsd-jsdoc.
@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.
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.
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.
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.
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.
@englercj Sorry for the delay - The "optional parameter" syntax is not working.
Just like @NewFuture , I am using @interface
(appropriate).
from tsd-jsdoc.
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.
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.
Ah, great catch! That certainly seems like the issue. Thanks for tracking this down.
from tsd-jsdoc.
(previous comment removed)
Thanks for handling this with us @NewFuture ! Thanks again for your work @englercj
from tsd-jsdoc.
Related Issues (20)
- ESLint for jsdoc doesn't recognize type `Class<T>` but does support `typeof T`
- @module name quotation marks included in declare module string
- Class specific callbacks HOT 11
- Incorrect warning: Failed to find parent of doclet HOT 4
- `@template` tag does not generate generic parameters HOT 2
- Possible to mark typedef / interface properties as readonly? HOT 2
- Using the word typeof in a doc comment breaks tsd-jsdoc output
- Syntax to get `this: this` into typings for function? HOT 2
- feature request: output filename
- How to generate with a ES5 JS file that is dependent on another library?
- Cannot instantiate type Cesium.Property. HOT 1
- keys may need quotes HOT 1
- Can this reexport classes?
- Support @event tag
- Add support for rest-parameter tuple types HOT 1
- Support <reference types="node" /> and adding import
- Typedefs with properties emit `type = { ... }` instead of an interface
- Support extends for typedef
- Using this library in conjunction with jsdoc-vuejs
- 'Failed to find parent of doclet' errors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tsd-jsdoc.