Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing types in index.d.ts #625

Open
bartocc opened this issue Nov 16, 2021 · 7 comments
Open

Missing types in index.d.ts #625

bartocc opened this issue Nov 16, 2021 · 7 comments

Comments

@bartocc
Copy link
Contributor

bartocc commented Nov 16, 2021

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'.

@snewcomer
Copy link
Collaborator

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

@bartocc
Copy link
Contributor Author

bartocc commented Nov 19, 2021

Yes, definitely

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

The later is more complete than the former

Do they serve different purposes or are they duplicates?

@bartocc
Copy link
Contributor Author

bartocc commented Jan 6, 2022

@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

@snewcomer
Copy link
Collaborator

Seems like they could in index.d.ts

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

@azhiv
Copy link

azhiv commented Feb 14, 2022

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[];
};

@bartocc
Copy link
Contributor Author

bartocc commented Feb 14, 2022

PR #635 just did this @azhiv

@azhiv
Copy link

azhiv commented Feb 14, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants