-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[AST] shape of Param, Pat and VarDeclarator #5416
Copy link
Copy link
Open
Description
Describe the bug
I don't think the typeAnnotation should be attached on pat.
1. VarDeclarator
The typeAnnotation should always be attached on the VarDeclarator, not the pat.
const a: number = 1, [b]: [number] = 2, { c }: { c: number } = { c: 3 };Expect:
VarDeclarator {
name: Pat,
init: Expr,
type_ann: TsTypeAnn,
};
Actual:
the type_ann is in the name.
2. Param
There should be a type_ann in the Param like VarDeclarator.
3. init in the Param
function foo(a = 1) { }
function bar(a: number = 1) { }Expect :
Param {
pat: Pat,
init: Expr,
type_ann: TsTypeAnn
}
Actual:
got AssignPat
It's better to remove typeAnnotation from Pat and add it to other AST struct like Param, VarDeclarator.
Input code
No response
Config
No response
Playground link
No response
Expected behavior
/
Actual behavior
No response
Version
N/A
Additional context
No response
Reactions are currently unavailable
