TypeScript and TSX grammars for tree-sitter.
Because TSX and TypeScript are actually two different dialects, this module defines two grammars. Require them as follows:
require('tree-sitter-typescript').typescript; // TypeScript grammar
require('tree-sitter-typescript').tsx; // TSX grammar
For Javascript files with flow type annotations you can use the the tsx
parser.
References
yum install nodejs
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
cargo install tree-sitter-cli
然后去掉package.json
中关于tree-sitter-cli
的安装。
npm install
npm run build
npm run test
npm run test-load
若报错error lto1: fatal error: bytecode stream in file ‘Release/obj.target/tree_sitter_javascript_binding/src/parser.o’ generated with LTO version 2.2 instead of the expected 7.3
,则将binding.gyp
中的编译指令更改如下:
# 添加"-fno-lto"
"cflags_c": [
"-std=c99",
"-fno-lto",
]
可能
tree-sitter-typescript
以及tree-sitter-javascript
都需要对应的更改。
先安装vs2022,并确保选上了Desktop development with C++
。
然后设置如下:
npm config set msvs_version 2022
若Python也需要设置,可以使用
npm config set python python3.10
.
然后遇到报错VCINSTALLDIR not set, not running in VS Command Prompt
, 可以参考 https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md#windows
-
有关dynamic precedence