microsoft / tsdoc

A doc comment standard for TypeScript
https://tsdoc.org/
MIT License
4.68k stars 131 forks source link

How to mark isOptional to true when using functions? #338

Open fenilli opened 1 year ago

fenilli commented 1 year ago

How to mark options as optional for this case? as it already has the ? but when using ApiParameterListMixin, it does not seen to have isOptional as true.

/**
 * Adds auto-animate to each input automatically.
 *
 * @param options - {@link https://github.com/formkit/auto-animate/blob/master/src/index.ts#L596 | AutoAnimateOptions }
 * @returns A compatible plugin to FormKit
 *
 * @public
 */
export function createAutoAnimatePlugin(
  options?: AutoAnimateOptions
): FormKitPlugin {

the code using it is

      (apiItem as ApiParameterListMixin).parameters.forEach(
        (parameter) => {
          const isOptional = parameter.isOptional ? '?' : '';
          console.log(parameter);
          parameters.push(`${parameter.name}${isOptional}: ${parameter.parameterTypeExcerpt.text.trim()}`);
        }
      )

// Gives this
<ref *1> Parameter {
  name: 'options',
  parameterTypeExcerpt: Excerpt {
    tokens: [
      [ExcerptToken],
      [ExcerptToken],
      [ExcerptToken],
      [ExcerptToken],
      [ExcerptToken]
    ],
    tokenRange: [Object: null prototype] { startIndex: 1, endIndex: 2 },
    spannedTokens: [ [ExcerptToken] ]
  },
  isOptional: false,
  _parent: ApiFunction {
    _tsdocComment: DocComment {
      configuration: [TSDocConfiguration],
      summarySection: [DocSection],
      remarksBlock: undefined,
      privateRemarks: undefined,
      deprecatedBlock: undefined,
      params: [DocParamCollection],
      typeParams: [DocParamCollection],
      returnsBlock: [DocBlock],
      modifierTagSet: [StandardModifierTagSet],
      _seeBlocks: [],
      _customBlocks: []
    },
    _excerptTokens: [
      [ExcerptToken],
      [ExcerptToken],
      [ExcerptToken],
      [ExcerptToken],
      [ExcerptToken]
    ],
    _excerpt: Excerpt {
      tokens: [Array],
      tokenRange: [Object],
      spannedTokens: [Array]
    },
    _fileUrlPath: undefined,
    _parent: ApiEntryPoint {
      _parent: [ApiPackage],
      _canonicalReference: undefined,
      [Symbol(ApiNameMixin._name)]: '',
      [Symbol(ApiItemContainerMixin._members)]: [Array],
      [Symbol(ApiItemContainerMixin._membersSorted)]: true,
      [Symbol(ApiItemContainerMixin._membersByContainerKey)]: [Map],
      [Symbol(ApiItemContainerMixin._preserveMemberOrder)]: false,
      [Symbol(ApiItemContainerMixin._membersByName)]: undefined,
      [Symbol(ApiItemContainerMixin._membersByKind)]: undefined
    },
    _canonicalReference: undefined,
    [Symbol(ApiExportedMixin._isExported)]: true,
    [Symbol(ApiReturnTypeMixin._returnTypeExcerpt)]: Excerpt {
      tokens: [Array],
      tokenRange: [Object: null prototype],
      spannedTokens: [Array]
    },
    [Symbol(ApiReleaseTagMixin._releaseTag)]: 4,
    [Symbol(ApiParameterListMixin._overloadIndex)]: 1,
    [Symbol(ApiParameterListMixin._parameters)]: [ [Circular *1] ],
    [Symbol(ApiTypeParameterListMixin._typeParameters)]: [],
    [Symbol(ApiNameMixin._name)]: 'createAutoAnimatePlugin'
  }
}

// function createAutoAnimatePlugin(options: AutoAnimateOptions)