-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Use ES6 "class" as module syntax #8359
Comments
This is to support browsers that don't yet support ES6 syntax without requiring a transpilation step. Here's a quote from our blog post going over the whole migration that I encourage you to check out:
With that said, having a transpilation is something we want to support in order to use newer ES6 syntax and features. Also from the blog:
I'm going to leave this open as a feature request to use this particular ES6 feature, since even if we do add a transpilation step it would have to be another effort to change how classes are declared. |
@OmarShehata I'm actually going to close this, the use of class will be part of a much larger discussion/decision/change so having this open as a standalone issue isn't really actionable. |
@mramato is there a different (good) place to discuss this publicly? I'm currently consuming Cesium from Typescript (c.f. #5717 #4434 etc) and I think I could fully automate that process if the "class-like" new-able function pattern that Cesium uses were to move to ES2015 class syntax. I explain in the "Typings" issue, but briefly, Typescript can successfully extract type information from JSDoc for almost all of Cesium, except where getter/setter functions are passed to As a small test case, I converted |
I think it's valid to have this issue open:
We will need to discuss the strategy for how to port over code. If we'd like to take a similar approach to how we moved to using prettier, we'd need some sort of automated method. I just came across Lebab, the opposite of Babel, for converting from ES5 syntax to ES6+. We'd need to do a test run to see if its possible to use for our codebase. |
Some brainstorming in terms of the strategy (even though some of that may be obvious): Two important dimensions are
For 1, some options are:
For 2. the options are ... well, at least everything that is listed as "Transforms" on https://github.com/lebab/lebab , and more... (Note: The considerations here are independent of whether we give 'lebab' a try or not. It seems unlikely for me that this could be a one-shot solution in general. And even if it was, technically, the following still has to be kept in mind: ) The possible modernization changes vary wildly in terms of their impact and their potential for "breaking" something. One recommendation from the lebap README is
and this also applies if we did certain changes manually. Note that these are really independent dimensions. For example, we could
I think that 2., "Which updates will be applied", can be answered more generically. A few random examples of the changes that could be part of such a modernization (roughly inspired by the lebab README):
Now... we can argue. Or vote 🙂 |
I'll start by saying I fully support swapping to
Even if this seems like the smallest effort up front I think of all the options this is the only one we should definitely not do. I think this approach can easily turn every PR into a mini-refactor and make them take longer. It also obfuscates the actual change of a PR. Much easier to review 1 pr for some change and a second PR that is only code restructure but should behave identically before and after. I think going section by section could work pretty well and unless we can fully automate transformation through something like
I think we should focus this issue and the subsequent PRs/changes on only the transition from Unrelated to your 2 points we may want to just take a peek at performance. I believe there were articles years ago when Some random articles I found doing a quick google
|
Although it probably does not make sense to try and talk through all degrees of freedom, scenarios, and granularities here, I think it's important to be aware that there are many degrees for this. The point is: There is no clear cut between "applying style and conventions" and "a refactoring". For example, when someone is touching a piece of code, and, say, adds another option to an
then one could make a case to just update this, to
iff (if an only if) the coding guidelines suggest that this is the preferred way (see #12196 ). Similarly, when someone is fixing a bug where some wrong argument is passed to a function as in
one could make a case to not just change the
However, this is related to the question of which changes are (supposed to be) applied. And when there is one, specific change, like the " |
So I can extend your class directly using
extends
,and so on.The text was updated successfully, but these errors were encountered: