Crate tree_sitter_typescript

source ·
Expand description

This crate provides TypeScript and TSX language support for the tree-sitter parsing library.

Typically, you will use the language function to add this language to a tree-sitter Parser, and then use the parser to parse some code:

use tree_sitter::Parser;

let code = r#"
function double(x: number): number {
    return x * 2;
}
"#;
let mut parser = Parser::new();
parser
    .set_language(&tree_sitter_typescript::language_typescript())
    .expect("Error loading TypeScript grammar");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

Constants§

Functions§