ember-cli-typescript icon indicating copy to clipboard operation
ember-cli-typescript copied to clipboard

new addon with ember-cli-typescript, adding @types/ember-data results in build failure

Open oliverlangan opened this issue 6 years ago • 5 comments

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> {
                                                       ~~~

oliverlangan avatar May 16 '19 21:05 oliverlangan

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!

chriskrycho avatar Jun 25 '19 13:06 chriskrycho

np, thanks Chris for all you do.

oliverlangan avatar Jun 26 '19 03:06 oliverlangan

Same issue here after adding "@types/ember-data": "^3.1.7".

luketheobscure avatar Aug 13 '19 23:08 luketheobscure

This issue mysteriously disappeared for us. I think I either had a missing dependency or something wrong in my tsconfig.

luketheobscure avatar Aug 14 '19 17:08 luketheobscure

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.

luketheobscure avatar Aug 29 '19 23:08 luketheobscure

I believe this has been resolved as of a few years ago, or at a minimum documented. Closing accordingly!

chriskrycho avatar Sep 28 '23 22:09 chriskrycho