-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Consider migrating the Jasmine codebase to Typescript or ECMAScript 6 #1800
Comments
I personally like working with Typescript so I've thought about this from time to time. There are a couple of problems that have stopped me from proposing it, though. My biggest concern is that Jasmine's own build toolchain might introduce polyfills or otherwise modify the global environment in such a way as to cause tests that should have failed to pass. E.g. if a user who intends to support IE inadvertently writes code that depends on promises, the tests should fail on IE. It would be unfortunate if Jasmine caused the tests to pass by poyfilling promises. See also my latest coment on #491. So I can see a few approaches:
|
Yeah, valid point. I guess that option 2 is not really acceptable. So, need to investigate option 1 |
It seems like Babel provides a way to polyfill features without modifying the global scope. However, it seem like some features can't be polyfilled this way: https://medium.com/@lee_85949/polyfilling-a-javascript-library-the-right-way-337806a54152 Anyway, I'm not a Babel/Webpack expert neither (unfortunately), so I won't be able to easily create a config for that. |
You might already know this, but (AFAIK) TypeScript never polyfills globals. If you try to use promises, but your compile target is Example playground link: https://www.typescriptlang.org/play?target=1&module=1#code/FAYw9gdgzgLgBABzgXjgBQE5gLYEsoCmAdBgVGADYBuBAFAJQDcQA |
It turns out that some problems can be solved by waiting until they go away. The upcoming 4.0 release (schedule: it will be ready when it's ready, but sometime 3-9 months from now is a reasonable guess) will drop support for IE and some older Safari versions. At that point we'll be able to use nearly all of ES2015 without transpiling. As for TypeScript, I don't think it's in the cards. I've gained some more experience converting JS codebases to TypeScript since this issue was first opened. That experience has me convinced that a TypeScript conversion is likely to exceed our dev time and risk budget, even for a major release where nothing else changes. It would also considerably raise the bar for contributing to Jasmine. Jasmine pushes the limits of TypeScript pretty hard, particularly in the matcher system. That's historically been one of the areas most contributed by people outside the core team. I'd rather not lose out on those contributions just because someone doesn't have a high level of TypeScript skill. |
Currently all the Jasmine codebase is written in pure Javascript, and we cannot use the latest, convenient ECMAscript features (like template strings, const/var declarations etc) to develop/maintain the Jasmine core functionality.
In order to be able to use the es6 features, the build process has to include transpilation from es6 (or higher)-compliant syntax to the older es syntax supported by all the browsers supported by Jasmine (including IE10).
One of the tools that can be used for transpiling the code is Babel.
Another option, however, would be to use Typescript. IMHO, this would enhance the project even more, because Typescript enables writing code faster and catching certain bugs during compilation. Any Typescript projects that use Jasmine for testing, would benefit from that as well, because currently the typings for Jasmine are not that good IMO, since they are not natively supported by Jasmine itself.
The text was updated successfully, but these errors were encountered: