通过查看拉取请求和问题,我看到node-tree-sitter模块中有打字稿定义(可能当前已过时) ;如何从 typescript 访问这些定义,以及 typescript 中以下 node-tree-sitter 示例 javascript 代码的等价物是什么?
const Parser = require('tree-sitter');
const JavaScript = require('tree-sitter-javascript');
const parser = new Parser();
parser.setLanguage(JavaScript);
const sourceCode = 'let x = 1; console.log(x);';
const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());