mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 02:53:31 +01:00
feat: more visibly annotate optionals
This commit is contained in:
@@ -39,6 +39,7 @@ export function CodeListing({
|
|||||||
{optional ? <Badge variant="filled">Optional</Badge> : null}
|
{optional ? <Badge variant="filled">Optional</Badge> : null}
|
||||||
<Title order={4} className="font-mono">
|
<Title order={4} className="font-mono">
|
||||||
{name}
|
{name}
|
||||||
|
{optional ? '?' : ''}
|
||||||
</Title>
|
</Title>
|
||||||
<Title order={4}>{separator}</Title>
|
<Title order={4}>{separator}</Title>
|
||||||
<Title order={4} className="font-mono break-all">
|
<Title order={4} className="font-mono break-all">
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import { Visibility } from '~/DocModel/Visibility';
|
|||||||
type MethodResolvable = ReturnType<DocMethod['toJSON']> | ReturnType<DocMethodSignature['toJSON']>;
|
type MethodResolvable = ReturnType<DocMethod['toJSON']> | ReturnType<DocMethodSignature['toJSON']>;
|
||||||
|
|
||||||
function getShorthandName(data: MethodResolvable) {
|
function getShorthandName(data: MethodResolvable) {
|
||||||
return `${data.name}(${data.parameters.reduce((prev, cur, index) => {
|
return `${data.name}${data.optional ? '?' : ''}(${data.parameters.reduce((prev, cur, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return `${prev}${cur.name}`;
|
return `${prev}${cur.isOptional ? `[${cur.name}]` : cur.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${prev}, ${cur.name}`;
|
return `${prev}, ${cur.isOptional ? `[${cur.name}]` : cur.name}`;
|
||||||
}, '')})`;
|
}, '')})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user