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

Updated types to support calling ObjectID() without the new keyword #41

Merged
merged 3 commits into from
Jan 17, 2022

Conversation

allouis
Copy link
Contributor

@allouis allouis commented Aug 25, 2021

This updates the typescript definitions file to allow calling the ObjectID class without new - as documented in the README and tests

We use interfaces here to allow us to define an object as both "newable" and callable.

We have one interface for the class constructor, this defines how to call it (new & as a function) as well as the static methods.

We then have another interface for the instance, this defines the members and methods.

We then have to export a const ObjectID so that typescript knows we are dealing with values, rather than types.

This adds type tests for calling ObjectID without new
We use interfaces here to allow us to define an object as both "newable"
and callable. We have one interface for the class constructor, this
defines how to call it (new & as a function) as well as the static
methods. We then have another interface for the instance, this defines
the members and methods.

We then have to export a const ObjectID so that typescript knows we are
dealing with values, rather than types.

ref https://discord.com/channels/508357248330760243/765583369345302570/879753593320796230
closes cabinjs#38

Since 2.0.0 the `generate` method has been removed from the ObjectID
class, this updates the types to reflect that.

refs cabinjs@a518e352
@niftylettuce niftylettuce merged commit 6780f29 into cabinjs:master Jan 17, 2022
@niftylettuce
Copy link
Collaborator

Released in v2.0.2 to npm

https://github.com/williamkapke/bson-objectid/releases/tag/v2.0.2

@allouis
Copy link
Contributor Author

allouis commented Jan 18, 2022

Thanks!!

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