tree-sitter / node-tree-sitter

Node.js bindings for tree-sitter
https://www.npmjs.com/package/tree-sitter
MIT License
649 stars 114 forks source link

Fix Typescript types #15

Closed wingrunr21 closed 6 years ago

wingrunr21 commented 6 years ago

These changes:

The correct way to do Typescript imports is now like this:

import * as Parser from 'tree-sitter';
import { Point, SyntaxNode, Tree } from 'tree-sitter';
maxbrunsfeld commented 6 years ago

Thanks for the great work and explanation @wingrunr21. I feel bad that I'm doing such a bad job at maintaining this as I make changes. It's because I don't personally use TypeScript.

We should really add some step to CI that makes sure that this file is valid. Do you have an idea of what that code would look like? One option would be to add it to the tree-sitter-cli CI build; that's where the tests are currently run, because the tests use both the CLI and this library.

wingrunr21 commented 6 years ago

I think a very quick typescript file that imports tree-sitter and checks for a clean compile should work. Typescript complained very quickly about the type definitions.

I think the harder part will be to make sure the various types stay in sync with the underlying native implementation.

I can give a CI PR a go if you'd like. I'm working to integrate this + the Ruby grammar into vscode-ruby so we'll be consuming it via Typescript.