node-tree-sitter
node-tree-sitter copied to clipboard
parseTextBuffer declaration is missing in TypeScript definitions file
I'm considering submitting a PR with updated TypeScript definitions (in particular the Query API), and since this issue is already open I figure why not use it.
I have a few questions though-- at present, the definitions are in tree-sitter.d.ts
, which is pointed to by the "types" field in package.json
. tree-sitter.d.ts
wraps everything in an ambient module declaration (declare module "tree-sitter"
). export =
is also included to define the final exported value.
I'm fairly new to TypeScript, so I might be wrong here, but this seems like an old and unnecessarily complex style. To simplify things, could we:
- change the
tree-sitter.d.ts
filename to index.d.ts (which typescript will find by default) - remove the "types" declaration in package.json (not needed because index.d.ts is the default name)
- remove the ambient module declaration (the declarations will be made available anyway as "tree-sitter" by virtue of being in
tree-sitter/index.d.ts
) - remove
export = Parser
, instead usingexport default class Parser
I think that these changes would simplify things, and, to my knowledge would not affect the API at all and so wouldn't break any existing code.
The issue described in the title of this PR was already fixed by #80. But @smackesey provided good suggestions, @maxbrunsfeld if you support all or parts of them I'd open PRs for node and wasm bindings to simplify TS declarations and to improve uniformity between both bindings.
Yeah, those changes sound good.
I tried @smackesey's suggestions but it didn't work, I think because the directory is named node-tree-sitter so its node-tree-sitter/index.d.ts instead of tree-sitter/index.d.ts