mirror of
https://github.com/discordjs/discord.js.git
synced 2026-06-01 16:40:07 +00:00
* fix(ExceptText): don't display import("d..-types/v10"). in return type
* Squashed 'packages/api-extractor-model/' content from commit 39ecb196c
git-subtree-dir: packages/api-extractor-model
git-subtree-split: 39ecb196ca210bdf84ba6c9cadb1bb93571849d7
* Squashed 'packages/api-extractor/' content from commit 341ad6c51
git-subtree-dir: packages/api-extractor
git-subtree-split: 341ad6c51b01656d4f73b74ad4bdb3095f9262c4
* feat(api-extractor): add api-extractor and -model
* fix: package.json docs script
* fix(SourcLink): use <> instead of function syntax
* fix: make packages private
* fix: rest params showing in docs, added labels
* fix: missed two files
* fix: cpy-cli & pnpm-lock
* fix: increase icon size
* fix: icon size again
80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
// See LICENSE in the project root for license information.
|
|
|
|
import type * as tsdoc from '@microsoft/tsdoc';
|
|
import { ApiDocumentedItem } from '../items/ApiDocumentedItem.js';
|
|
import type { ApiParameterListMixin } from '../mixins/ApiParameterListMixin.js';
|
|
import type { Excerpt } from '../mixins/Excerpt.js';
|
|
|
|
/**
|
|
* Constructor options for {@link Parameter}.
|
|
*
|
|
* @public
|
|
*/
|
|
export interface IParameterOptions {
|
|
isOptional: boolean;
|
|
isRest: boolean;
|
|
name: string;
|
|
parameterTypeExcerpt: Excerpt;
|
|
parent: ApiParameterListMixin;
|
|
}
|
|
|
|
/**
|
|
* Represents a named parameter for a function-like declaration.
|
|
*
|
|
* @remarks
|
|
*
|
|
* `Parameter` represents a TypeScript declaration such as `x: number` in this example:
|
|
*
|
|
* ```ts
|
|
* export function add(x: number, y: number): number {
|
|
* return x + y;
|
|
* }
|
|
* ```
|
|
*
|
|
* `Parameter` objects belong to the {@link (ApiParameterListMixin:interface).parameters} collection.
|
|
* @public
|
|
*/
|
|
export class Parameter {
|
|
/**
|
|
* An {@link Excerpt} that describes the type of the parameter.
|
|
*/
|
|
public readonly parameterTypeExcerpt: Excerpt;
|
|
|
|
/**
|
|
* The parameter name.
|
|
*/
|
|
public name: string;
|
|
|
|
/**
|
|
* Whether the parameter is optional.
|
|
*/
|
|
public isOptional: boolean;
|
|
|
|
/**
|
|
* Whether the parameter is a rest parameter
|
|
*/
|
|
public isRest: boolean;
|
|
|
|
private readonly _parent: ApiParameterListMixin;
|
|
|
|
public constructor(options: IParameterOptions) {
|
|
this.name = options.name;
|
|
this.parameterTypeExcerpt = options.parameterTypeExcerpt;
|
|
this.isOptional = options.isOptional;
|
|
this.isRest = options.isRest;
|
|
this._parent = options.parent;
|
|
}
|
|
|
|
/**
|
|
* Returns the `@param` documentation for this parameter, if present.
|
|
*/
|
|
public get tsdocParamBlock(): tsdoc.DocParamBlock | undefined {
|
|
if (this._parent instanceof ApiDocumentedItem && this._parent.tsdocComment) {
|
|
return this._parent.tsdocComment.params.tryGetBlockByName(this.name);
|
|
}
|
|
|
|
return undefined;
|
|
}
|
|
}
|