Skip to content

fix(dts-generator): support rest parameters in functions in nested types #507

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

Merged
merged 2 commits into from
Jun 24, 2025

Conversation

akudev
Copy link
Member

@akudev akudev commented Jun 6, 2025

When api.json contains:
Object<string,function(...any)>|function

Then the d.ts file will contain:
Record<string, (...p1: any) => void> | Function;

Before this fix, the function had no parameter.

@akudev akudev requested a review from codeworrior June 6, 2025 07:42
1.)
When no param and no return type is given, generate "Function" instead
of "()=>void" to allow passing parameters, just like it happens in
simple function types.

2.)
When api.json contains:
Object<string,function(...any)>|function

Then the d.ts file will contain:
Record<string, (...p1: any) => void> | Function;

Before this fix, the function had no parameter.
@akudev akudev force-pushed the fix/nestedRestParams branch from 487c2c2 to b39de70 Compare June 6, 2025 08:45
| TypeReference
| TypeLiteral
| UnionType
| IntersectionType
| ArrayType
| FunctionType
| LiteralType
| NativeTSTypeExpression;
| NativeTSTypeExpression
) & { repeatable?: boolean };
Copy link
Member

Choose a reason for hiding this comment

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

It is an anachronism in JSDoc that the "repeatable" information is attached to the type (because JSDoc has no parameter names in function signatures, only types) and our api.json inherited this from JSDoc.

I would rather convert this in the ts-ast-type-builder as we do already for the optional flag.

Copy link
Member

@codeworrior codeworrior left a comment

Choose a reason for hiding this comment

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

LGTM

@akudev akudev merged commit 095bae6 into main Jun 24, 2025
7 checks passed
@akudev akudev deleted the fix/nestedRestParams branch June 24, 2025 06:22
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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy