On a fresh ember project with ember-cli-typescript installed the generators for typescript are not working. I tested with an older version of ember-cli (2.18) on my system and that worked as expected.
Steps to reproduce:
Let me know if there is any other information needed to reproduce, I'll include the contents of my package.json here.
package.json:
{
"name": "example",
"version": "0.0.0",
"private": true,
"description": "Small description for example goes here",
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"repository": "",
"scripts": {
"build": "ember build",
"lint:js": "eslint ./*.js app config lib server tests",
"start": "ember serve",
"test": "ember test"
},
"devDependencies": {
"@types/ember": "^2.8.9",
"@types/ember-data": "^2.14.8",
"@types/ember-test-helpers": "^0.7.0",
"@types/ember-testing-helpers": "^0.0.3",
"@types/rsvp": "^4.0.1",
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-cli": "~3.0.0",
"ember-cli-app-version": "^3.0.0",
"ember-cli-babel": "^6.6.0",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-eslint": "^4.2.1",
"ember-cli-htmlbars": "^2.0.1",
"ember-cli-htmlbars-inline-precompile": "^1.0.0",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-qunit": "^4.1.1",
"ember-cli-shims": "^1.2.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-typescript": "^1.1.2",
"ember-cli-uglify": "^2.0.0",
"ember-data": "~3.0.0",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-resolver": "^4.0.0",
"ember-source": "~3.0.0",
"eslint-plugin-ember": "^5.0.0",
"loader.js": "^4.2.3",
"typescript": "^2.7.1"
},
"engines": {
"node": "^4.5 || 6.* || >= 7.*"
}
}
Thanks for the report @sdhawley! I'm going to be testing a fix for this tomorrow 鈥撀爄t seems to be an ordering issue, since the generators also come from ember-source and ember-data, which are also "just addons" from Ember CLI's perspective.
Hi @chriskrycho , it looks like it is taking longer than expected, is there a workaround I can try until the fix is checked in?
@sdhawley Ah, sorry, I meant to update this when I realized I wasn't going to get to it.
Your best bet is to just convert the generated files from .js to .ts by hand, and it turns out that we don't want the individual file generators to include the type registries. You should instead create a registry file something like this:
my-app/
types/
my-app/
index.d.ts
registry/ <- this folder
services.d.ts <- and this type declaration
Then in types/my-app/index.d.ts:
// For TS resolution
import './registry/services';
And in types/my-app/registry/services.d.ts:
import SomeService from 'my-app/services/some-service';
declare module '@ember/service' {
interface Registry {
'some-service': SomeService;
}
}
[I have a branch locally where I'm working on automating that with the generators, but it'll probably be next week (at the earliest) before I can get it integrated. I have a ton of stuff to get done for the day job this week and my open-source time is mostly focused on building the [EmberConf workshop](https://emberconf.com/speakers.html#chris-krycho) I'm teaching in three weeks.]
This should be fixed by #152 (turns out "9 days ago" !== "issue #9")
Most helpful comment
Thanks for the report @sdhawley! I'm going to be testing a fix for this tomorrow 鈥撀爄t seems to be an ordering issue, since the generators also come from ember-source and ember-data, which are also "just addons" from Ember CLI's perspective.