oak_typescript/ast/root_nodes.rs
1use crate::ast::Statement;
2use core::range::Range;
3
4/// TypeScript AST root node.
5#[derive(Debug, Clone)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7pub struct TypeScriptRoot {
8 /// Statements in the root.
9 pub statements: Vec<Statement>,
10 /// Source span of the root.
11 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
12 pub span: Range<usize>,
13}
14
15impl TypeScriptRoot {
16 /// Creates a new `TypeScriptRoot`.
17 pub fn new(span: Range<usize>) -> Self {
18 Self { statements: vec![], span }
19 }
20}