tree-sitter / tree-sitter-typescript

TypeScript grammar for tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: tree-sitter-typescript not working with my tree-sitter library in javascript

precious112 opened this issue · comments

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues of tree-sitter-typescript

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

I have been trying to get tree-sitter-typescript to work in javascript but i's not working always throwing the error Invalid language object but tree-sitter works well with tree-sitter-javascript and tree-sitter-python. here's my code :

const Parser  = require('tree-sitter');
const Typescript= require('tree-sitter-typescript').typescript;

const parser= new Parser();
parser.setLanguage(Typescript);```

### Steps To Reproduce/Bad Parse Tree

```const path = require('path');
const Parser  = require('tree-sitter');
const Typescript= require('tree-sitter-typescript').typescript;

const parser= new Parser();
parser.setLanguage(Typescript);```

### Expected Behavior/Parse Tree

```const path = require('path');
const Parser  = require('tree-sitter');
const Typescript= require('tree-sitter-typescript').typescript;

const parser= new Parser();
parser.setLanguage(Typescript);```

### Repro

```TypeScript
// Example code that causes the issue
function foo() {
  // Code that fails to parse, or causes an error
}

I'm pretty sure this is because this package has not been updated to be compatible with tree sitter v21. I'm having a similar problem with the Rust crate - the Language struct is incompatible with tree-sitter v21