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

Missing types in index.d.ts

Open bartocc opened this issue 4 years ago • 7 comments

It is great to have a type definitions file index.d.ts, but it looks like it has not been updated since a long time and is now quite incomplete.

In our codebase, we often use the imports listed below and they generate TS errors.

Version

3.15.0

Steps to reproduce

Add the following imports in a *.ts file

import { Changeset } from "ember-changeset";
import { EmberChangeset } from "ember-changeset";

Expected Behavior

No TS error

Actual Behavior

Module '"ember-changeset"' has no exported member 'Changeset'. Module '"ember-changeset"' has no exported member 'EmberChangeset'.

bartocc avatar Nov 16 '21 09:11 bartocc

Thx! And you are right. Would you be up for putting together a pr?

snewcomer avatar Nov 16 '21 11:11 snewcomer

Yes, definitely

I am a bit confused though… there are 2 type definition files

  • https://github.com/poteto/ember-changeset/blob/master/index.d.ts
  • https://github.com/poteto/ember-changeset/blob/master/types/index.d.ts

The later is more complete than the former

Do they serve different purposes or are they duplicates?

bartocc avatar Nov 19 '21 09:11 bartocc

@snewcomer could you help me understand why these 2 definition files exist?

The way I see it, they could/should be merged… but I might be missing something…

Thx

bartocc avatar Jan 06 '22 11:01 bartocc

Seems like they could in index.d.ts

https://github.com/poteto/ember-changeset/blob/master/package.json#L21

snewcomer avatar Feb 04 '22 02:02 snewcomer

It would also be great to add correct typings for Changeset function, namely its last parameter - option, since the addon supports passing a custom changeset class into it:

if (options.changeset) {
  return new options.changeset(obj, validateFn, validationMap, options);
}

Current definition only exposes two keys for the hash:

export type Config = {
  skipValidate?: boolean;
  changesetKeys?: string[];
};

azhiv avatar Feb 14 '22 05:02 azhiv

PR https://github.com/poteto/ember-changeset/pull/635 just did this @azhiv

bartocc avatar Feb 14 '22 07:02 bartocc

Ok, cool! Looking forward to get a fresh release with all the changes.

azhiv avatar Feb 14 '22 07:02 azhiv