mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +01:00
style: change how optionals are displayed
This commit is contained in:
@@ -11,10 +11,10 @@ type MethodResolvable = ApiMethodJSON | ApiMethodSignatureJSON;
|
|||||||
function getShorthandName(data: MethodResolvable) {
|
function getShorthandName(data: MethodResolvable) {
|
||||||
return `${data.name}${data.optional ? '?' : ''}(${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.isOptional ? `[${cur.name}]` : cur.name}`;
|
return `${prev}${cur.isOptional ? `${cur.name}?` : cur.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${prev}, ${cur.isOptional ? `[${cur.name}]` : cur.name}`;
|
return `${prev}, ${cur.isOptional ? `${cur.name}?` : cur.name}`;
|
||||||
}, '')})`;
|
}, '')})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,15 +43,14 @@ export function ParametersSection({ data }: { data: ParameterDocumentation[] })
|
|||||||
export function ConstructorSection({ data }: { data: ApiConstructorJSON }) {
|
export function ConstructorSection({ data }: { data: ApiConstructorJSON }) {
|
||||||
const matches = useMediaQuery('(max-width: 768px)', true, { getInitialValueInEffect: false });
|
const matches = useMediaQuery('(max-width: 768px)', true, { getInitialValueInEffect: false });
|
||||||
|
|
||||||
function getShorthandName(): string {
|
const getShorthandName = () =>
|
||||||
return `constructor(${data.parameters.reduce((prev, cur, index) => {
|
`constructor(${data.parameters.reduce((prev, cur, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return `${prev}${cur.isOptional ? `[${cur.name}]` : cur.name}`;
|
return `${prev}${cur.isOptional ? `${cur.name}?` : cur.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${prev}, ${cur.isOptional ? `[${cur.name}]` : cur.name}`;
|
return `${prev}, ${cur.isOptional ? `${cur.name}?` : cur.name}`;
|
||||||
}, '')})`;
|
}, '')})`;
|
||||||
}
|
|
||||||
|
|
||||||
return data.parameters.length ? (
|
return data.parameters.length ? (
|
||||||
<Section title="Constructor" icon={<VscSymbolMethod />} padded dense={matches}>
|
<Section title="Constructor" icon={<VscSymbolMethod />} padded dense={matches}>
|
||||||
|
|||||||
Reference in New Issue
Block a user