mzgol
Re:jQuery Core: Migrate from AMD to ES modules
on Wednesday November 20, 2019 @09:22AM (#21584118)
Not everything can be handled by a minifier. Consider multiple accesses of `item.prop` where `prop` is optional. You can cache `item.prop` in a variable to avoid multiple checks but the minifier usually cannot revert it back to the previous form as it has to take into account the possibility that `item.prop` is a getter in which case such a replacement would potentially change semantics.
Re:jQuery Core: Migrate from AMD to ES modules
on Wednesday November 20, 2019 @09:13AM (#21584038)
Thanks for the terminology fix. With lots of these assertions, especially in the form of `x as unknown as TheProperType` we wouldn't have to increase file size but that would nullify most of the TypeScript gains and would make the code more readable. If we wanted to make internal code more in line with what TypeScript expects, that would require code changes which I expect may increase the file size, though.
I haven't done any real testing on the jQuery code base but that's my experience working on some TypeScript projects.
Re:jQuery Core: Migrate from AMD to ES modules
on Wednesday November 20, 2019 @08:16AM (#21583599)
A nice thing is you can import from `src/jquery.js` directly from the browser without any build process in every modern browser.
https://gist.github.com/mgol/af95c1358d4ca9f2d45db4f0c55a74a...
Re:jQuery Core: Migrate from AMD to ES modules
on Wednesday November 20, 2019 @07:18AM (#21583219)
Some of jQuery APIs wouldn't be that easy to convert to TS internally, we'd have to have lots of casting and most likely file size would suffer and that's one thing we care a lot about in the jQuery team. Plus, that would be a barrier for some contributors.
The @types/jquery package is maintained quite well so TS users can consume a typed jQuery anyway.
So, no plans to switch to TypeScript (or to ES6+ with the exception for imports) for now.