ember-changeset icon indicating copy to clipboard operation
ember-changeset copied to clipboard

[Typescript] Incorrect return type of functions `changeset` and `Changeset`

Open bartocc opened this issue 3 years ago • 0 comments

I might be wrong, but I believe the EmberChangeset return type I used in #641 is not completely correct: https://github.com/poteto/ember-changeset/blob/aac0b2cecf09acc3be24c55265311fe0fb87a9f6/index.d.ts#L15-L16

If we pass an EmberChangeset subclass to the options param changeset, the return type won't be EmberChangeset, but the subclass.

For example

class MyChangeset extends EmberChangeset {}
const cs = Changeset({foo: "bar"}, () => true, {}, {changeset: MyChangeset})

Then the cs variable will be of type MyChangeset, not EmberChangeset

@kpfefferle Do you agree?

bartocc avatar Apr 13 '22 13:04 bartocc