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_TYPESCRIPT constant 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();
let language = tree_sitter_typescript::LANGUAGE_TYPESCRIPT;
parser
.set_language(&language.into())
.expect("Error loading TypeScript parser");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());
Constants
- The syntax highlighting query for TypeScript.
- The tree-sitter
LanguageFn
for TSX. - The tree-sitter
LanguageFn
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.