Re:jQuery Core: Migrate from AMD to ES modules
by mzgol 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
by mzgol 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.
In short, I strongly doubt that the need for type assertions would meaningfully impact jQuery file size.