Compile TypeScript to JavaScript before executing #941
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This basically compiles from TypeScript to JavaScript at runtime when the "Run" button is clicked.
However, there are currently 2 issues worth mentioning:
1. Speed
Notice that this is noticeably slow because it's using
tsc
. It could possibly be improved by usingesbuild
,swc
,babel
or something similar but then there will be no typechecking when the "Run" button is clicked.However, I think the above typechecking caveat will not make much sense when we have real-time Intellisense in the editor for TypeScript.
2. Sourcemaps
Another consideration is the lack of sourcemap support in GJS. While tsc can generate sourcemaps, this feature is disabled because GJS won't use them. This means that some errors will have the wrong line:column information.
For example:
Workbench/GJS reports the error is on line number 17 even if it's actually on line number 22 because that's where it ends up after it's compiled to JavaScript (many compilers will eat up unnecessary line breaks even though the minify option is turned off).
I left some TODOs in here where some decisions need to be made and hope to get some feedback