The generated parser TypeScript types currently declare BindingIdentifier.typeAnnotation as always null, but the parser can emit a real TSTypeAnnotation for binding identifiers.
Reference discussion: https://discord.com/channels/1079625926024900739/1080712024683708466/1500159726980432084
AI disclosure: this issue text was drafted with AI assistance and reviewed before filing.
Reproduction
Parse a TypeScript binding identifier with a type annotation, for example:
The parsed AST includes a BindingIdentifier whose typeAnnotation is populated:
{
type: "Identifier",
name: "x",
typeAnnotation: {
type: "TSTypeAnnotation",
typeAnnotation: {
type: "TSStringKeyword"
}
}
}
Current Type Definition
In types.d.ts, BindingIdentifier is currently generated as:
export interface BindingIdentifier extends Span {
type: "Identifier";
decorators?: [];
name: string;
optional?: false;
typeAnnotation?: null;
parent?: Node;
}
Expected
IdentifierReference.typeAnnotation should remain null, because annotations are not valid on identifier references:
const y = x: string; // invalid
But BindingIdentifier.typeAnnotation should allow a real TypeScript annotation, because bindings can be annotated:
Expected type:
export interface BindingIdentifier extends Span {
type: "Identifier";
decorators?: [];
name: string;
optional?: false;
typeAnnotation?: TSTypeAnnotation | null;
parent?: Node;
}
Notes
This appears to be a generated type mismatch rather than a parser AST output issue. The generated files point to:
tasks/ast_tools/src/generators/typescript.rs
as the source for types.d.ts generation.
The generated parser TypeScript types currently declare
BindingIdentifier.typeAnnotationas alwaysnull, but the parser can emit a realTSTypeAnnotationfor binding identifiers.Reference discussion: https://discord.com/channels/1079625926024900739/1080712024683708466/1500159726980432084
AI disclosure: this issue text was drafted with AI assistance and reviewed before filing.
Reproduction
Parse a TypeScript binding identifier with a type annotation, for example:
The parsed AST includes a
BindingIdentifierwhosetypeAnnotationis populated:Current Type Definition
In
types.d.ts,BindingIdentifieris currently generated as:Expected
IdentifierReference.typeAnnotationshould remainnull, because annotations are not valid on identifier references:But
BindingIdentifier.typeAnnotationshould allow a real TypeScript annotation, because bindings can be annotated:Expected type:
Notes
This appears to be a generated type mismatch rather than a parser AST output issue. The generated files point to:
as the source for
types.d.tsgeneration.