-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[WASM] Converting runtime JS to TS #55871
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
Good work. Always nice to see the world becoming a better place by reducing js locs. |
+ made extra type files declaration files
@terrajobst I am an intern on @lewing 's team. So I am internal to MSFT :). |
…ck types + tried to fix the build error
Would it be possible to rename these to binding-support.js etc., our convention is to use '-' in file names instead of '_'. |
Reviewers please also review the types. I had to guess them so there are bound to be errors or better types availableI specifically left no implicit |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsWORK IN PROGRESSThis PR renames the What's changedBasically everything is as it was only now the files support typescript's type system. So we can better document the functions and have a better development experience as this also has the side effect of adding syntax checking and a few other linting features to the build and VS Code. Most types can be included directly in the source code, however for some additional types, such as for C functions, there is a new Also, now we can use enums to help minimize the guessing with what types are supported for what operations. They can be added to the declaration files via The How does the new build workThe same as before except that now, before calling TODO list
|
We have at least 3 different things treated as
|
It would be good to diff original js before and compiled js after to make sure that functional changes are reviewed. |
I am not familiar enough with these details so I agree the best way will probably be to leave them as number for this PR and then over time gradually improve them as we update the files. |
I did a diff and looks like it is the same code just it uses spaces rather than tabs, some comments are intentionally removed and some spacing between functions, variables, etc. is optimized. However this is expected as |
@lewing @pavelsavara Is there still ongoing work w/ this PR? |
yes, I will take it over. |
Replaced by #59392 |
This PR renames the
dotnet_support.js
,binding_support.js
andlibrary_mono.js
files todotnet_support.ts
,binding_support.ts
andlibrary_mono.ts
and converts them to use typescript.What's changed
Basically everything is as it was only now the files support typescript's type system. So we can better document the functions and have a better development experience as this also has the side effect of adding syntax checking and a few other linting features to the build and VS Code.
Most types can be included directly in the source code, however for some additional types, such as for C functions, there is a new
types
folder.Also, now we can use enums to help minimize the guessing with what types are supported for what operations. They can be added to the declaration files via
declare const enum
. During compilation they will be automatically replace with their raw values.The
tsc
compiler runs during the build but can be invoked manually viatsc -p <path to runtime folder>
or viamake js-from-ts
from the MakeFile in thesrc/mono/wasm
folder.How does the new build work
The same as before except that now, before calling
emcc
to package the js intodotnet.js
, we call thetsc
compiler to convert the TS to JS. Then theemcc
can run as before with the only difference being that the js files are located in a newly generated build folder.TODO list
tsc
(all you need is to runnpm i -g typescript
to install the tool globally)tsc
to CI if it isn't already there (it isn't: [dotnet\runtime WASM] Added typescript dotnet-buildtools-prereqs-docker#481)