Skip to content

Commit dd1ee58

Browse files
feat(unstable): align lint ast with TSEStree (#27996)
This PR fixes deviations in our AST format compared to TSEStree. They are mostly a leftover for when I first started working on it and based it off of babel instead. One of the key changes why the changeset is a bit bigger is that TSEStree uses `undefined` instead of `null` as the empty value for type nodes. This is likely influenced by `tsc` which use `undefined` everywhere. The rest of the nodes use `null` though. It's a little weird, but for now it might be better to align. (extracted from #27977)
1 parent 89b1969 commit dd1ee58

File tree

5 files changed

+2158
-964
lines changed

5 files changed

+2158
-964
lines changed

cli/tools/lint/ast_buffer/buffer.rs

+16
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,22 @@ impl SerializeCtx {
485485
};
486486
}
487487

488+
/// Helper for writing optional node offsets with undefined as empty value
489+
pub fn write_maybe_undef_ref<P>(
490+
&mut self,
491+
prop: P,
492+
parent: &PendingRef,
493+
value: Option<NodeRef>,
494+
) where
495+
P: Into<u8> + Display + Clone,
496+
{
497+
if let Some(v) = value {
498+
self.write_ref(prop, parent, v);
499+
} else {
500+
self.write_undefined(prop);
501+
};
502+
}
503+
488504
/// Write a vec of node offsets into the property. The necessary space
489505
/// has been reserved earlier.
490506
pub fn write_ref_vec<P>(

0 commit comments

Comments
 (0)