-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript support #870
Comments
I suggest to use For types, we will decide what types we need to use. Christopher Davis has nice precompiled types here: https://gitlab.gnome.org/BrainBlasted/gi-typescript-definitions. Although I'm unsure on the rate on which they get regenerated. I'll try to familiarise myself with LSPs as I don't really know how they work currently and how they're used in Workbench. |
Is esbuild able to retain line numbers?
Evan is working on merging the various projects so let's wait for that? |
A couple of thoughts on this Evan is working on merging ts-for-gir and gi.ts gjsify/ts-for-gir#144 but we don't need to wait for it to get started. There is now a TypeScript SDK extension https://github.com/flathub/org.freedesktop.Sdk.Extension.typescript that we can use and recommend similar to the Rust and Vala SDK extensions. We use Biome for formatting and diagnostics of JavaScript. Biome also supports TypeScript so let's try using Biome as well for TypeScript. I don't want to write all demos in both JS and TS - so we should write them in TS and have a tool that automatically strips the types to generate the I think the best way forward is
Each step can be done and merged independently |
No, but I'm failing to understand why it's necessary
That means we won't get type checking. Which is the entire point of typescript. Or did you mean we can use one of gi.ts or ts-for-gir while waiting for the merge?
tsc will do that, but will be extremely slow. esbuild is a faster approach. No tool that I know of will retain lines, at least on purpose. This is because typescript also has features that cannot be mapped to JS and as such will require different code, such as enums or decorators. However, most tools will generate source maps. These are all my concerns, and some of them may not be valid. What do you think? |
GJS does not support source maps ATM which means that if the compiler doesn't retain lines we get wrong line numbers in stack traces.
You are commenting on a sentence that ends with "to get started" :)
As I said; Babel does. |
I have a weird idea: since workbench can intercept the errors, what if we get the correct line numbers from the intercepted errors using a generated source map before logging the error? Of course I don't know if it's feasible and it could be better if upstreamed to GJS.
Sorry. My brain possibly skipped that part 😓
Hmm. Okay, Babel can be used initially then. But this does not inspire confidence, imo:
|
yeah ok I guess that even if we get the right error line we still get the wrong column maybe inaccurate stack traces is not that bad until GJS gets source maps - we can put up a warning |
Great news, GJS has merged support for source maps https://gitlab.gnome.org/GNOME/gjs/-/merge_requests/938 It will ship with GNOME 48. That means we can get accurate stack traces for both TypeScript and JavaScript (compiled from TypeScript at build time) see workbenchdev/demos#201 |
we should support TypeScript
We can iterate on this and go like this
Extensions.js
- TypeScript should not run if it's not enabledbuild-aux/library.js
compile TypeScriptmain.ts
files to equivalentmain.js
files (and run biome formatter over them)The text was updated successfully, but these errors were encountered: