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§
- The syntax highlighting query for TypeScript.
- The local-variable syntax highlighting query for TypeScript.
- The symbol tagging query for TypeScript.
- The content of the
node-types.json
file for TSX. - The content of the
node-types.json
file for TypeScript.