-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't working
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
Relevant Package
ast-spec
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Description
NewExpression
and CallExpression
are basically identical in terms of arguments list. Among others, you're perfectly fine with spreading arguments in both of them:
class A { constructor(...args: unknown[]) {} }
const a = new A(...someArray);
const F = (...args: unknown[]) => {}
const f = F(...someArray);
That is reflected in CallExpression
type:
export interface CallExpression extends BaseNode { | |
type: AST_NODE_TYPES.CallExpression; | |
callee: LeftHandSideExpression; | |
arguments: CallExpressionArgument[]; |
With
CallExpressionArgument
being:export type CallExpressionArgument = Expression | SpreadElement; |
At the same time, NewExpression
typing allows only Expression
arguments:
export interface NewExpression extends BaseNode { | |
type: AST_NODE_TYPES.NewExpression; | |
callee: LeftHandSideExpression; | |
arguments: Expression[]; |
SpreadElement
is not there, even though it is legal to spread arguments in constructor call (playground)
Fail
n/a
Pass
n/a
Additional Info
No response
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't working