Strongly-typed AST types for TypeScript, auto-generated from
tree-sitter-typescript's node-types.json.
This crate is generated by treesitter-types and is
automatically kept up to date when a new version of the grammar crate is released.
These types have been tested by parsing the TypeScript source code.
See the Tree-sitter project for more information about the underlying parser framework.
Example
use *;
// A minimal TypeScript hello-world program.
let src = b"\
function greet(name: string): void {
console.log(\"Hello, \" + name + \"!\");
}
greet(\"World\");
";
// Parse the source with tree-sitter and convert into typed AST.
let mut parser = new;
parser
.set_language
.unwrap;
let tree = parser.parse.unwrap;
let program = from_node.unwrap;
// The program has two top-level children.
assert_eq!;
// 1) The function declaration — `function greet(name: string): void { ... }`.
let Statement = &program.children else ;
let Declaration = stmt.as_ref else ;
let FunctionDeclaration = decl.as_ref else ;
assert_eq!;
assert_eq!; // one parameter: `name: string`
assert!; // has return type `: void`
// 2) The call expression — `greet("World");`.
let Statement = &program.children else ;
let ExpressionStatement = call_stmt.as_ref else ;
assert_eq!;