adopted-ember-addons / ember-data-model-fragments

Ember Data addon to support nested JSON documents
MIT License
370 stars 114 forks source link

[Types] `FragmentArray` accepts registry key, should accept full fragment class #444

Closed charlesfries closed 2 years ago

charlesfries commented 2 years ago

The new unreleased type declarations want me to type FragmentArray like this:

import type { FragmentArray } from 'ember-data-model-fragments/attributes';

interface Args {
  model: FragmentArray<'user'>;
}

and not like this:

import type { FragmentArray } from 'ember-data-model-fragments/attributes';
import type UserModel from 'my-app/models/user';

interface Args {
  model: FragmentArray<UserModel>;
}

Shouldn't we be passing in the full class to the generic? Otherwise iterating over fragment array just yields the registry keys instead of the actual objects, according to the TypeScript declarations.