Join Stack Overflow to learn, share knowledge, and build your career. Connect and share knowledge within a single location that is structured and easy to search. Something like the following doesn't work, how can I do? Learn more. JSdoc use variable as default value Ask Question. Asked 4 years, 6 months ago. Active 4 years, 6 months ago.

Viewed times. I have a class that takes an options object with a lot of configurations inside.

Carnage 2021 cast

Fez Vrasta Fez Vrasta Doesn't work how? It crashes? It does not look the way you want? If the latter, then what does it look like, and what would you like it to look like instead? Add a comment. Active Oldest Votes. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Best practices can slow your application down.

Featured on Meta. Visual design changes to the review queues. Survey questions for outdated answers. Introducing Outdated Answers project. Related 5. Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled.Have a question about this project?

Worst aspects in synastry

Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Already on GitHub?

Thug names for instagram

Sign in to your account. In issue 27 commentsindresorhus asked:. I've opened a new issue since I think it's a separate topic from the defaultValue tag. The text was updated successfully, but these errors were encountered:. My initial instinct would be to say that TSDoc should not be involved with parameter defaults, because the information is already clearly expressed in the source code.

But there's a hitch.

The TypeScript compiler does not propagate this information into the generated. For example, you might get output like this:. So it does seem that the doc comments need to express this somehow.

I went and looked at JSDoc for comparison. Their param tag spuports a special notation for this. It uses [] to indicate an optional parameter which is redundant in TypeScript, but is maybe a useful grouping mechanism. If we follow that approach, we'd get something like this:. This could work, however TSDoc seeks to be a rigorous and syntactically complete language.

I have a number of design questions about JSDoc's notation:. Why aren't string literals enclosed in quotes? Or what the title was "] -"?Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Already on GitHub? Sign in to your account. However there doesn't seem to be a way to represent this in JSDoc, TypeScript seems to just split template on comma and take the longest identifier. This proposal is to extend template in JSDoc to support generic defaults e.

The syntax isn't really important, but the capability would be helpful. I don't think this would cause any grammar issues but I'm not sure.

The text was updated successfully, but these errors were encountered:. Well, I like the color of your bikeshed.

jsdoc default value

You know, as long as it doesn't end up making anything explode In the case of functions, typescript could also infer the default value of a generic parameter from the default value of the parameter it is bounded to.

Here I would expect Typescript to infer that the type of test1 is number[] nulland the type of test2 is number[]. Currently version 3. The OP's "bikeshedding" does not give a syntax for a type parameter that is both constrained and includes a default value.

The former syntax more closely matches paramand I don't think there are any other examples of syntax similar to the latter, as far as I can see. Has there been any opinion from the team about this? I see weswigham is the only contributor participating?

I just linked to this issue from tsd-jsdoc and it would be great if tsd-jsdoc and the TS team could all align on a syntax that works for everybody. Though, to be fair, template is not specified in core JSDoc, it's a Closure extension, so the JSDoc compiler should already be ignoring it.

This is a pretty severe blocker for me, since I express all my types in JSDoc, and want to add template parameters in a backward-compatible way especially to take an existing type and turn it into a template without breaking callers.

My only other option that I'd prefer not to, is to move the many interdependent declarations into a. I want to chime in as well, I've been using JSDoc as a way to add compile safety to my plain JS code, and it's been a mostly pleasant experience, until I hit this limitation. I second the following syntax, as it preserves the current behavior and mirrors default type assignments in TypeScript:.Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account. For example:. Correctly parsing the above parameter requires matching brackets except inside stringswhich is impossible in a normal regular expression and difficult in an extended one which I'm not sure Javascript supports.

Fashioned meaning in kannada

The text was updated successfully, but these errors were encountered:. Skip to content.

New issue. Jump to bottom. Labels feature. Milestone 3. Copy link. Fix for jsdoc - Allow default values for parameters to contain br… …. We solve this by redefining splitName in terms of splitNameMatchingBrackets which tries to find the matching end bracket if the name starts with an open bracket. Ignores brackets inside strings. If splitNameMatchingBrackets fails to find the closing bracket, we fall back to the original regex method. Adding tests for fix jsdoc ….

Without the fix, we get the following when running. Stacktrace: undefined 2 should allow default values to have brackets Message: Expected '"user"]] - Path split into components' to be 'Path split into components'. Stacktrace: undefined 4 should allow default values to have brackets inside strings Message: Expected 'begin: ["]] - Path split into components' to be 'Path split into components'.

Stacktrace: undefined Finished in 5. Fixed on master. Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment.

Linked pull requests. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window.Have a question about this project?

Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Already on GitHub?

Sign in to your account. Copied from my SO question:.

jsdoc default value

I expected to be able to extract the default value of a JsDoc param but I'm actually unable to find the default value on the JsDoc node. For example, give this:. I'd like to extract 42 from the node. Yet I find no default value field on the ts node:.

It exposes isBracketed but I cannot find the Typescript does claim to support default JsDoc arguments:. Yet I cannot seem to find the exposed in the AST And that's because, it's not currently in the AST!

The parser currently skips over the expression without storing the return value anywhere. I would use TS except I cannot express that a key must be a symbol! So you guys owe me! And then my equally glorious documentation can include the default value:. I'd guess this would be fairly trivial to expose on the AST. Just have to decide on a name.

Maybe defaultValue?

Subscribe to RSS

Or rawDefaultValue just so I can return the string without concern for its type? Or maybe just a node that I can pull the raw text out of?The param tag requires you to specify the name of the parameter you are documenting.

You can also include the parameter's type, enclosed in curly brackets, and a description of the parameter. The parameter type can be a built-in JavaScript type, such as string or Objector a JSDoc namepath to another symbol in your code.

If you have written documentation for the symbol at that namepath, JSDoc will automatically link to the documentation for that symbol. You can also use a type expression to indicate, for example, that a parameter is not nullable or can accept any type; see the type tag documentation for details. If you provide a description, you can make the JSDoc comment more readable by inserting a hyphen before the description. Be sure to include a space before and after the hyphen. The following examples show how to include names, types, and descriptions in a param tag.

jsdoc default value

You can add a hyphen before the description to make it more readable. If a parameter is expected to have a specific property, you can document that property by providing an additional param tag. For example, if an employee parameter is expected to have name and department properties, you can document it as follows:.

If a parameter is destructured without an explicit name, you can give the object an appropriate one and document its properties. You can also combine this syntax with JSDoc's syntax for array parameters.

For example, if multiple employees can be assigned to a project:. The following examples show how to indicate that a parameter is optional and has a default value. The following examples show how to use type expressions to indicate that a parameter can accept multiple types or any typeand that a parameter can be provided more than once.

See the type tag documentation for details about the type expressions that JSDoc supports. If a parameter accepts a callback function, you can use the callback tag to define a callback type, then include the callback type in the param tag.She was so efficient and catered to our every need. We had an absolute blast and anyone who travels to Scandinavia should definitely book and travel with Nordic Visitor!. Jeffrey and Kristin, United States Northern Lights City Break, January 2016 We tell everyone we know to go to Iceland and to use your company if they go.

Even met people in Iceland who were with another company, and after listening to us, they took down your information. We have enjoyed every tour we've taken with your company. Rachel, United Kingdom Northern Lights City Break, December 2015 Anita was fabulous, I booked my trip almost a year in advance and had endless questions and Anita always got back to me quickly and in a very polite manner.

She is superb and is a huge credit to your organisation.

jsdoc default value

The trip was everything I wished it to be and more, thank you. Kayla, United States Golden Triangle - Starting in Copenhagen, December 2015 Nordic Visitor made everything SO EASY. Catherine and Scott, United States Volcanic Iceland, November 2015 The Hotel was in the perfect location for us. The Tour Guide was very knowledgeable about the areas (history, geology). I think he made this the most memorable trip we have ever had.

My husband and I would not have had as much fun on a big bus tour with lots of people so we were not sure what this tour would be like.

It was a small group (just us. We loved the city, and loved the trip - again, this was the perfect trip for us. I am very glad I found Nordic Visitor. I am not a very experienced traveler, but wanted to get out and see another part of the world. My husband and I have already talked about going back to Iceland and we expect to book with Nordic Visitor again. Thanks for such a great experience. Lindsey, United States Northern Lights Circle Tour, November 2015 The tour was amazing.

Our guide was extremely knowledgeable about the geology and history of Iceland. She pointed out many things we would have missed on our own.

There was trouble with the sound system on the bus the first day, but she arranged a replacement. We have been talking about going to Iceland for a chance to see the northern lights for over ten years.

This trip exceeded all of my expectations. We were lucky enough to see the northern lights at the beginning of the trip, which fulfilled the dream. When people ask how the trip was, I struggle to answer them.

There are no words to describe how wonderful everything was. Benjamin and Andrew, United Kingdom Icelandic Winter Highlights, November 2015 Our tour guide was excellent and ensured out experience was as smooth as possible. She was incredibly enthusiastic and considered the time we wanted to spend at certain locations, and stopped at additional locations that she knew we would enjoy whenever possible.

Wallace, United States Pearls of the South and West - Winter, November 2015 We enjoyed both the quality and variety of accommodations in our program. Patricia, Costa Rica Scenic Fjords of Norway, October 2015 We had a great experience booking our tour with Nordic Visitor. The web site is very easy to follow.

All questions were answered quickly and it was easy to book with clear instructions and vouchers for the trips. Sara our agent did a great job. Everything was perfect, hotels, transportations, her tips for other activities. We really enjoyed our trip. Simon, Canada Nordic Odyssey, October 2015 All the hotels were fantastic. If any UK clients want to ask any points then do contact me.


thoughts on “Jsdoc default value

Leave a Reply

Your email address will not be published. Required fields are marked *