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

Add generic parameter to AwilixContainer interface #169

Merged
merged 1 commit into from
Feb 28, 2020
Merged

Add generic parameter to AwilixContainer interface #169

merged 1 commit into from
Feb 28, 2020

Conversation

roikoren755
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Feb 28, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 4b69c64 on roikoren755:master into c1d3256 on jeffijoe:master.

src/container.ts Outdated
@@ -42,7 +42,7 @@ export interface AwilixContainer {
/**
* Creates a scoped container with this one as the parent.
*/
createScope(): AwilixContainer
createScope<T extends object = any>(): AwilixContainer<T>
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldn't this be

Suggested change
createScope<T extends object = any>(): AwilixContainer<T>
createScope<T extends object = any>(): AwilixContainer<Cradle & T>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, my bad

src/container.ts Outdated
}
export type NameAndRegistrationPair<T> = Partial<
{
[U in keyof T]: Resolver<T[U]>
Copy link
Owner

Choose a reason for hiding this comment

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

Remove Partial and use

Suggested change
[U in keyof T]: Resolver<T[U]>
[U in keyof T]?: Resolver<T[U]>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -43,9 +43,9 @@ export type NameFormatter = (
/**
* Dependencies for `loadModules`
*/
export interface LoadModulesDeps {
export interface LoadModulesDeps<T extends object> {
Copy link
Owner

Choose a reason for hiding this comment

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

loadModules is dynamic already, I don't think we need to worry about it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't need to worry in this file altogether? or just this interface and its uses?

Copy link
Owner

Choose a reason for hiding this comment

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

I think the entire file. Loading modules from the file system can never provide any static type analysis.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted this file

@jeffijoe
Copy link
Owner

One last favor before we release, could you check out awilix-koa and link your local awilix and run the lint + test? Want to confirm that this isn't a breaking change type-wise, as I don't want to cut a major release just for a type change. 🙏

@roikoren755
Copy link
Contributor Author

One last favor before we release, could you check out awilix-koa and link your local awilix and run the lint + test? Want to confirm that this isn't a breaking change type-wise, as I don't want to cut a major release just for a type change. 🙏

Just did, and everything passed. Just to be sure, what I did to test it was change the awilix entries in the awilix-koa package.json to be file:../awilix, and then ran yarn lint and yarn test

@jeffijoe
Copy link
Owner

Sounds good, last step is squashing your commits into 1 commit. If you don't want to, I can do a Squash and Merge on GH but it's not as nice. 😄

Remove unnecessary conversions

CR fix

Revert
@roikoren755
Copy link
Contributor Author

Done :)

@jeffijoe
Copy link
Owner

Fantastic, thank you!

@jeffijoe jeffijoe merged commit 7eca2e5 into jeffijoe:master Feb 28, 2020
@moltar moltar mentioned this pull request Apr 12, 2020
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.

3 participants