Ember and TypeScript

I don’t understand. Without transitioning the Ember object model to TS classes, how are you going to get type assertions/inferencing/checking on properties, which is the whole point?

I don’t know why Ember should need a complete reset like Angular only for adopting TypeScript. I think the first step is the JavaScript Modules API RFC then we can think about changing the internals of the Ember Object Model and then it should be “easy” to adopt TypeScript. Until all the work is done (and everybody can contribute**), you can still develop your app and upgrade when everything is ready for prime time. I think that’s much nicer than knowing that everything you develop today has to be thrown away because the underlying framework is completely rewritten. But that’s just my point of view.

**) and its better to contribute than to invest time and energy in complaining about things.

I’m deeply confused by your deeply confusing comment. I totally fail to understand why my choice not to spend some meaningful percentage of my personal time working on Ember disqualifies me from expressing my opinion. Is that actually what you are saying, because it sure sounds that way.

The only way for Ember to move into a true TS world is a large-scale conversion effort. If you think that will not involve changing Ember in a way that will require a large migration effort for existing apps, and a large re-learning effort for existing users, or that the JS modules RFC is some kind of meaningful step along the way to doing the TS move, then you are simply revealing your ignorance about both TS and Ember,

That’s a little too much salt if you ask me, but that’s none of my business

It doesn’t disqualify you from expressing your opinion. We live in a free world. Whether we, who work for free in our spare time, can immediately fulfill your request is about resources. If you would help, or pay someone to work on it, it might get done faster. Generally the contributors get the features they want faster, because they make it happen.

I don’t think anyone wants to convert in its entirety, all at once, an existing Ember app into a TS app. What they want to be able to do is have a migration path for those who can, and keep going the old way if they want. And be able to start new apps using the new way. And for bonus points, add some TS classes to an existing Ember app and migrate over time. And for even more bonus points, get some leverage from TS without changing anything. I think that is possible, with the understanding some typing benefits will be lost in those mixed applications. Am I ignorant? Maybe. I don’t claim to be all-knowing.

2 Likes

You are correct, we can do this incrementally fairly easily, and we are. At some point soon, and soon is probably “about a year”, without any changes people will just be able to write some or all of their apps in typescript to their heart’s content.

furthermore, Glimmer is written in TypeScript, and it’s core object (also TypeScript) is very similar to Ember.Object. There’s honestly very little about Ember.Object that keeps us from using TypeScript. TypeScript isn’t a different language.

I’m sorry if you felt offended. This was not my intention. Sure you can express your opinion. And I can express my opinion too. I still think it is possible to pave the road to TypeScript without rewriting everything. But it would be interesting to see examples which show why you think a whole rewrite is needed. The statement “Ember’s object model is not compatible” is a little bit to abstract for me. Maybe you could explain that in more detail and with some code examples.

And I agree with @Gaurav0 that no one will rewrite an entire app at once. So for us it would be ok to stay with js-files for old code and gradually switch them over to TypeScript. Yes we will lose some benefits if we mix JS and TS but I prefer the incremental approach over the “big-bang” approach.

But yeah, maybe I don’t see the real problems. Would be great if @rtm could explain them to me. Probably this is possible with some pseudo-code samples.

Check this section, it sorta gives you an idea of why it’s not compatible

Yes I see, but I don’t know why you couldn’t wrap all this functionality into TypeScript classes and then just use or extend these classes. Then of course you wouldn’t replace the Ember-Objects with “pure” TypeScript classes but I’m not sure if this is necessary.

2 Likes

@chilicoder sounds like great news :smile:

How do the new TypeScript changes help us in the short term, and how do they help us in the long term? I got excited when I read that tweet, too, but didn’t know if it was immediately useful or just paving the way for a better future.

@rosshadden I had exactly the same question in mind. Hopefully someone could explain it to us :slight_smile:

There was a very interesting mini-talk at the Ember-Conf, you can watch it here: https://youtu.be/ZCHFjGSCqP4?t=6h34m26s

1 Like

Hi everyone!

I’d like to mention another TypeScript-related news from EmberConf, for those who missed it :wink:

We have released Glimmer! The rendering engine that powers Ember can now be used to build independent UI components, complete with a Web Component wrapper for ease of use. As Glimmer is written in TypeScript, it could provide a glimpse into what Ember could look like in the future, as we carry out the integration work of bringing angle bracket components into Ember.

4 Likes

There shouldn’t be anything about Ember CLI that prevents you from using TypeScript, see broccoli-typescript-compiler and ember-cli-typescript, which uses the former. Instead of creating a gulp task, you create a broccoli plugin and hook it into the pipeline, like how ember-cli-coffeescript and it’s TypeScript equivalent do.

2 Likes

That’s great idea. I’ll try to do that. I think it’s also needed to create some guides with best practises when using typescript in Ember (for example how to properly get and set properties to Ember Object). I see that many ppl (especially those, who came from strong typed languages) prefers TS over JS. In my company there are many ActionScript (which is strong typed lang) programmers who would like to switch to EmberJS and i think it’ll be easier for them to use TS in Ember.

Totally agree, I think that’s one of the major missing parts at the moment: how to use these new building blocks in a proper way? Do we have any good example repos using ember-cli-typescript we can look at?

Hi!

We have been working on getting TypeScript to type check our Ember app, and as a kind of experiment we created an addon, which enables out-of-the-box type checking and compilation of Ember apps.

While this addon is experimental and still in an early stage, it can already find a lot of type errors, thanks to the TypeScript 2.x features (keyof, lookup types, indexed signatures, ThisType),

The addon can be found here:

Please try it out and share your thoughts!

5 Likes