Skip to content

Conversation

@btea
Copy link
Contributor

@btea btea commented Dec 24, 2025

Description

It should be consistent with the return type format shown in the table below, with different types separated by |.

image

Validation

Related Issues

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

Copilot AI review requested due to automatic review settings December 24, 2025 03:18
@btea btea requested a review from a team as a code owner December 24, 2025 03:18
@vercel
Copy link

vercel bot commented Dec 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
api-docs-tooling Ready Ready Preview Dec 24, 2025 1:46pm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses formatting inconsistency in function return types by ensuring that union types (separated by |) have consistent spacing. The change modifies the signature generation logic to normalize return type formatting from string|number to string | number, matching the documentation table format.

Key Changes

  • Modified return type string processing to split on pipes, trim whitespace, and rejoin with proper spacing
  • Applied formatting normalization to all function and method signatures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@avivkeller
Copy link
Member

I wonder if this can be done in CSS, since each word is its own span

@btea
Copy link
Contributor Author

btea commented Dec 24, 2025

before after
image image

I think it should still be handled in the JavaScript. Based on the current page rendering, it seems that |undefined will be placed in the same span.

Comment on lines +6 to +45
describe('generateSignature - return type spacing', () => {
it('formats union return types without spaces as spaced ("|" surrounded)', () => {
const sig = generateSignature(
'foo',
{
params: [],
return: { type: 'string|number' },
},
''
);

assert.equal(sig, 'foo(): string | number');
});

it('preserves already spaced union return types', () => {
const sig = generateSignature(
'bar',
{
params: [],
return: { type: 'Promise<string> | undefined' },
},
''
);

assert.equal(sig, 'bar(): Promise<string> | undefined');
});

it('omits return type when undefined', () => {
const sig = generateSignature(
'baz',
{
params: [],
return: undefined,
},
''
);

assert.equal(sig, 'baz()');
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe('generateSignature - return type spacing', () => {
it('formats union return types without spaces as spaced ("|" surrounded)', () => {
const sig = generateSignature(
'foo',
{
params: [],
return: { type: 'string|number' },
},
''
);
assert.equal(sig, 'foo(): string | number');
});
it('preserves already spaced union return types', () => {
const sig = generateSignature(
'bar',
{
params: [],
return: { type: 'Promise<string> | undefined' },
},
''
);
assert.equal(sig, 'bar(): Promise<string> | undefined');
});
it('omits return type when undefined', () => {
const sig = generateSignature(
'baz',
{
params: [],
return: undefined,
},
''
);
assert.equal(sig, 'baz()');
});
});
describe('generateSignature', () => {
it('formats union return types without spaces as spaced ("|" surrounded)', () => {
const sig = generateSignature(
'foo',
{
params: [],
return: { type: 'string|number' },
},
''
);
assert.equal(sig, 'foo(): string | number');
});
it('preserves already spaced union return types', () => {
const sig = generateSignature(
'bar',
{
params: [],
return: { type: 'Promise<string> | undefined' },
},
''
);
assert.equal(sig, 'bar(): Promise<string> | undefined');
});
it('omits return type when undefined', () => {
const sig = generateSignature(
'baz',
{
params: [],
return: undefined,
},
''
);
assert.equal(sig, 'baz()');
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants