dop251 / goja

ECMAScript/JavaScript engine in pure Go
MIT License
5.63k stars 378 forks source link

DefinitelyTyped for goja and goja-node? #608

Open benallfree opened 2 months ago

benallfree commented 2 months ago

Over at https://github.com/pocketbase/pocketbase/discussions/5512 we are having a discussion about the PocketBase JSVM typings, and I recognize that goja's core and node typings underly PocketBase's extensions.

Do you know if there has been any discussion or attempts at creating something like @types/goja and @types/goja-node? It would be hugely useful for anyone using TS to target a Goja environment.

dop251 commented 2 months ago

There hasn't been any discussion as far as I'm aware, but neither goja, nor goja_nodejs define any types of their own (except maybe for GoError).

benallfree commented 2 months ago

For example, @types/node introduces many typings and modules that are not available in the goja environment. It seems that es2020 is fairly suitable for defining the basic goja types. Can you help me understand if there might be suitable typings existing already?

dop251 commented 2 months ago

There is a long-standing issue about listing all ECMAScript features and their status. Unfortunately, I haven't had time for it so far. Having said that, most of the features are there, so taking es2020 as a basis is not a bad shot.

As for node, very few modules have been implemented, and most of those that are implemented are incomplete, so no, I don't think there are suitable typings available.