Skip to content

Commit d8d80a9

Browse files
committed
fix(ast/estree): fix TS types for BigIntLiteral and RegExpLiteral (#9091)
The `value` fields of these 2 types are `null` in the JSON AST, but they're converted to `BigInt` or `RegExp`s on JS side. Adjust the TS type definitions accordingly.
1 parent af59945 commit d8d80a9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/oxc_ast/src/ast/literal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub struct StringLiteral<'a> {
106106
value = crate::serialize::NULL,
107107
bigint = crate::serialize::bigint_literal_bigint(self),
108108
),
109-
add_ts = "value: null, bigint: string",
109+
add_ts = "value: BigInt, bigint: string",
110110
)]
111111
pub struct BigIntLiteral<'a> {
112112
/// Node location in source code
@@ -129,7 +129,7 @@ pub struct BigIntLiteral<'a> {
129129
#[estree(
130130
rename = "Literal",
131131
add_fields(value = crate::serialize::NULL),
132-
add_ts = "value: null",
132+
add_ts = "value: RegExp | null",
133133
)]
134134
pub struct RegExpLiteral<'a> {
135135
/// Node location in source code

npm/oxc-types/types.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -810,15 +810,15 @@ export interface StringLiteral extends Span {
810810
export interface BigIntLiteral extends Span {
811811
type: 'Literal';
812812
raw: string | null;
813-
value: null;
813+
value: BigInt;
814814
bigint: string;
815815
}
816816

817817
export interface RegExpLiteral extends Span {
818818
type: 'Literal';
819819
regex: RegExp;
820820
raw: string | null;
821-
value: null;
821+
value: RegExp | null;
822822
}
823823

824824
export interface RegExp {

0 commit comments

Comments
 (0)