-
Notifications
You must be signed in to change notification settings - Fork 21
fix: add spaces between different return types of functions #531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this 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.
|
I wonder if this can be done in CSS, since each word is its own |
| 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()'); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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()'); | |
| }); | |
| }); |


Description
It should be consistent with the return type format shown in the table below, with different types separated by
|.Validation
Related Issues
Check List
node --run testand all tests passed.node --run format&node --run lint.