tree-sitter / tree-sitter-typescript

TypeScript grammar for tree-sitter
MIT License
332 stars 103 forks source link

Update the bindings #288

Closed segevfiner closed 2 months ago

segevfiner commented 3 months ago

Still need to adjust the Makefile for the C bindings, review the Rust bindings for any updates needed, and update the workflows.

Checklist

segevfiner commented 3 months ago

Fixed the Go bindings.

The rest of the bindings build the grammar into a single shared library, I see no reason that it must have two separate libraries, I was able to modify the makefile to produce one...

ObserverOfTime commented 3 months ago

The rest of the bindings build the grammar into a single shared library, I see no reason that it must have two separate libraries, I was able to modify the makefile to produce one...

One of the purposes of the C bindings is to build libraries that can be used in editors and Neovim for one can't load multiple languages from the same library.

Fixed the Go bindings.

You also need to update the test.

func TestCanLoadTypeScriptGrammar(t *testing.T) {
    language := tree_sitter.NewLanguage(tree_sitter_typescript.TypeScriptLanguage())
    if language == nil {
        t.Errorf("Error loading TypeScript grammar")
    }
}

func TestCanLoadTSXGrammar(t *testing.T) {
    language := tree_sitter.NewLanguage(tree_sitter_typescript.TSXLanguage())
    if language == nil {
        t.Errorf("Error loading TSX grammar")
    }
}
GSiesto commented 2 months ago

As someone new to the library, I'm leveraging this thread to seek clarification.

I'm exploring the TypeScript grammar integration with Python (https://github.com/tree-sitter/py-tree-sitter) and noticed there isn't a pip package for TypeScript grammar, similar to the ones for Python grammar (https://github.com/tree-sitter/tree-sitter-python/tree/master/bindings) and JavaScript grammar (https://github.com/tree-sitter/tree-sitter-javascript/tree/master/bindings).

I am trying to avoid building the typescript library. I may have overlooked something, so I'm reaching out for clarification. Is there a reason for this?

This is especially relevant considering the deprecation notice on the python py-tree-sitter repository, which advises when speaking about building the libraries:

This method of loading languages is deprecated and will be removed in v0.22.0. It should only be used for languages that lack updated bindings, and a C compiler will be necessary in those instances.

https://github.com/tree-sitter/py-tree-sitter?tab=readme-ov-file#build-from-source

Any insights you can share would be greatly appreciated

gruebel commented 2 months ago

hey @segevfiner I think you forgot to also update tree-sitter in the Cargo.toml

[dependencies]
tree-sitter = "~0.20.10" -> "~0.21.0"
amaanq commented 2 months ago

superseded by #294