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

fix: export types for chai extensions #789

Merged
merged 1 commit into from
Apr 27, 2021

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Apr 27, 2021

If a chai extension has types they cannot be resolved by modules that depend
on aegir unless those types are in a definitely-typed-style @types/chai-foo
module.

This seems to be because we don't export them from the utils/chai.js
file so they are not referenced from anywhere, then when we try to use
chai with the extensions from another module their types have not been
loaded so chai's base types are not extended and we have missing methods
everywhere. Unless of course, they are in a @types/... module in which case
typescript's default module resolution algorithm will find them, though more
by accident than by design.

Here we export the chai extensions, ensuring their types will be loaded
by the generated .d.ts file, then delete the exported property as we don't
really want to export the extensions.

If a chai extension has types it cannot be resolved unless those types
are in a definitely typed style `@types/chai-something` module.

This seems to be because we don't export them from the `utils/chai.js`
file so they get removed during compilation, then when we try to use
the extensions their types have not been loaded so chai's base types are
not extended and we have missing methods everywhere.

Here we export the chai extensions, ensuring their types will be loaded
then delete the exported property as we don't really want to export the
extensions.
Copy link
Member

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch 👍🏼

@achingbrain achingbrain merged commit a6f5ac9 into master Apr 27, 2021
@achingbrain achingbrain deleted the fix/export-types-for-chai-extensions branch April 27, 2021 18:04
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

Successfully merging this pull request may close these issues.

2 participants