ember-cli-typescript
ember-cli-typescript copied to clipboard
new addon with ember-cli-typescript, adding @types/ember-data results in build failure
ember -v
ember-cli: 3.10.0 (also seen with earlier versions, back to 3.5.0) node: 10.15.3 os: darwin x64
tsc -v
Version 3.4.5
ember-cli-typescript and ember-cli-typescript-blueprints
[email protected] [email protected]
What are instructions we can follow to reproduce the issue?
ember addon foo-bar --yarn
cd foo-bar
ember b # succeeds
ember install ember-cli-typescript@latest --save
ember b # succeeds
yarn add @types/ember-data
ember b # fails
Result:
WARNING: foo-bar has added the class-properties plugin to its build, but ember-cli-babel provides these by default now! You can remove the transforms, or the addon that provided them, such as @ember-decorators/babel-transforms.
WARNING: foo-bar has added the class-properties plugin to its build, but ember-cli-babel provides these by default now! You can remove the transforms, or the addon that provided them, such as @ember-decorators/babel-transforms.
Environment: development
node_modules/@types/ember-data/index.d.ts:960:52 - error TS2344: Type 'any' does not satisfy the constraint 'never'.
960 class Snapshot<K extends keyof ModelRegistry = any> {
~~~
Hey, thanks for the report and sorry for the delay! I'll see if this is still reproducible with the changes that have landed in the interval sometime soon!
np, thanks Chris for all you do.
Same issue here after adding "@types/ember-data": "^3.1.7".
This issue mysteriously disappeared for us. I think I either had a missing dependency or something wrong in my tsconfig.
Finally figured this out! If you've got @types/ember-data installed, you need to add the file in types/ember-data/types/registries/model.d.ts with this:
export default interface ModelRegistry {
[key: string]: any;
}
This should be added automatically by ember-cli-typescript, but if for some reason it's not there you'll hit the error you described.
I believe this has been resolved as of a few years ago, or at a minimum documented. Closing accordingly!