poteto / ember-changeset

Ember.js flavored changesets, inspired by Ecto

Home Page:http://bit.ly/ember-changeset-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

bartocc opened this issue · comments

I might be wrong, but I believe the EmberChangeset return type I used in #641 is not completely correct:

export function changeset(...args: changesetFunctionsParameters): EmberChangeset;
export function Changeset(...args: changesetFunctionsParameters): EmberChangeset;

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?