Skip to content

Commit 120c924

Browse files
Adjust span in non pretty serialiser too
1 parent 7de389c commit 120c924

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: crates/oxc_ast/src/serialize.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ const JSON_CAPACITY_RATIO_PRETTY: usize = 80;
3737

3838
impl Program<'_> {
3939
/// Serialize AST to ESTree JSON, including TypeScript fields.
40-
pub fn to_estree_ts_json(&self) -> String {
40+
pub fn to_estree_ts_json(&mut self) -> String {
41+
// Set start span to first token of first statement.
42+
if let Some(first_stat) = self.body.first() {
43+
self.span = Span::new(first_stat.span().start, self.span.end);
44+
}
45+
4146
let capacity = self.source_text.len() * JSON_CAPACITY_RATIO_COMPACT;
4247
let mut serializer = CompactTSSerializer::with_capacity(capacity);
4348
self.serialize(&mut serializer);

0 commit comments

Comments
 (0)