mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +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}
|
||||
<Title order={4} className="font-mono">
|
||||
{name}
|
||||
{optional ? '?' : ''}
|
||||
</Title>
|
||||
<Title order={4}>{separator}</Title>
|
||||
<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']>;
|
||||
|
||||
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) {
|
||||
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