TypeScript package for ember app?

Good morning all!

I’m trying to build a TypeScript package that will be consumed by an ember app. No glimmer components, just data structures, and some vanilla functions.

I was curious if anyone had some boilerplate that includes a build system and test suite.

Thanks!

Have you seen EmberCLI TypeScript? It’s an addon that will compile .ts files. I’ve used it on two projects so far, for utilities only. There are some limitations, for example there’s no clean way to write Ember Objects as TypeScript classes. But it sounds like it might do the trick for your usecase

I’ve not got any examples handy, maybe I can look at creating one if people are having trouble

Thanks! Saw the add on and prototyped the project with it :grin:. However, I just want to move the code into its own package and test suite.

Have you tried it within an ember add on?

Unfortunately there are some issues with using it in an ember Addon. People are working on it, but I don’t see it being fixed in the next few weeks as it seems to be a tangle in the Addon system

Another approach, which I’m looking into for a non-Ember project, is to use the underlying Broccoli plugin. I was going to start with the Glimmer build helper to see how they use it. Guess you could also look under the hood of EmberCLI TypeScript

Hi, perhaps you might be interested to try out (and give feedback on :slight_smile: ) our experimental TypeScript 2.x addon? It should be able to type check both your .js and .ts (because of the --allowJs and --checkJs flags being enabled).

The addon includes rewritten declarations which (although not complete) support proper this binding in Ember methods, amongst other things. For more details check the README:

Link: GitHub - draios/ember-typescript2: Drop-in Ember CLI addon for TypeScript 2.3+ (experimental)

Note: we are especially interested in getting feedback on our approach to a “model and service” index, which enables type cheching stuff like this.store.createRecord('user') and Ember.service.inject('myservice') without additional type annotations in your code.