0

I am currently trying to import my own created grammar in a typescript node project in the following way:

import Parser = require('tree-sitter');
import Language = require('tree-sitter-own');

This throws the error:

Cannot find module 'tree-sitter-own' or its corresponding type declarations.

In the package file under dependencies it is imported as follows:

"dependencies": {
        "tree-sitter-own": "file:../../tree-sitter-own"
}

If I check the node_modules folder it got correctly installed and copied over. There are however no type definition files in the tree-sitter grammar. How can you correctly import a grammar in node or how can you correctly add type declarations so typescript can use it?

1 Answers1

0

Try to build your grammar using WASM and then require it.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 31 '22 at 04:55