question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: @defaultValue to indicate a default value

See original GitHub issue

In API Extractor issue #720 @RueDeRennes asked about supporting @default to indicate a default value.

Some questions:

  • Should this be part of core TSDoc?
  • Should the tag be @default or @defaultValue?
  • Should it apply only to properties and fields? What about function parameters?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:12
  • Comments:10

github_iconTop GitHub Comments

4reactions
octogonzcommented, Sep 19, 2018

Based on the discussion with office-ui-fabric-react, we’re thinking @default tag would have the following spec:

  • The tag must only be used with fields or properties that are members of a class or interface. For example, @default should NOT be applied to a function or class declaration.
  • It’s a normal block tag, which means that it captures all text including multiple paragraphs until the next block tag or the end of the comment.
  • That content should be thought of as English prose that would appear on a web site under a heading such as ‘Default Value’.
  • In most cases the default value will be code symbols, which should be quoted using a code span (single backticks) or code fence (triple backticks).

Usage example:


enum WarningStyle {
  DialogBox,
  StatusMessage,
  LogOnly
}

interface IWarningOptions {
  /**
   * Determines how the warning will be displayed.
   *
   * @remarks
   * See {@link WarningStyle| the WarningStyle enum} for more details.
   * 
   * @default `WarningStyle.DialogBox`
   */
  warningStyle: WarningStyle;

  /**
   * Whether the warning can interrupt a user's current activity.
   * @default 
   * The default is `true` unless
   *  `WarningStyle.StatusMessage` was requested.
   */
  cancellable?: boolean;

  /**
   * The warning message
   */
  message: string;
}
3reactions
octogonzcommented, Mar 15, 2019

How about documenting default function parameters? What will that look like?

@sindresorhus After thinking about this question, I don’t think @defaultValue is the right tag for this. I opened a separate GitHub issue to discuss your question: https://github.com/Microsoft/tsdoc/issues/151

Read more comments on GitHub >

github_iconTop Results From Across the Web

defaultValue
This block tag is used to document the default value for a field or property, if a value is not assigned explicitly. This...
Read more >
set multiple default values to RFC
You can only set one default value to one parameter. The default value is what will be put in the parameter if a...
Read more >
DefaultValue Property
Specifies a String value that is automatically entered in a field when a new record is created. For example, in an Addresses table...
Read more >
NetSuite Applications Suite - Field.defaultValue
addField({ id : 'custpage_textfield', type : serverWidget.FieldType.TEXT, label : 'Text' }); field.defaultValue = 'Insert Text Here.'; .
Read more >
With-defaults Capability for NETCONF RFC 6243
This document defines a capability-based extension to the NETCONF protocol that allows the NETCONF client to identify how defaults are processed by the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found