-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
refactor: enable type checks inside mixin classes #5394
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are places where our implementation contained a bug that was discovered after type checks were enabled 👇
@@ -57,26 +48,42 @@ export function BootMixin<T extends Constructor<any>>(superClass: T) { | |||
() => this.projectRoot, | |||
); | |||
this.bind(BootBindings.BOOT_OPTIONS).toDynamicValue( | |||
() => this.bootOptions, | |||
() => this.bootOptions ?? {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This problem was hidden by any
before.
this.mountComponentBooters(component); | ||
return binding; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This problem was hidden by any
before.
this.mountComponentRepositories(component); | ||
const binding = super.component(componentCtor, nameOrOptions); | ||
this.mountComponentRepositories(componentCtor); | ||
return binding; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This problem was hidden by any
before.
0186756
to
4c03819
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 👍
4c03819
to
f1e862c
Compare
Introduce a new type helper `MixinTarget` allowing mixin functions to accept a type that describes public members of the target class only. This is working around the current TypeScript limitations. Rework all existing mixins and the related documentation to use `MixinTarget<RealClass>` instead of `Constructor<any>`. Fix any errors discovered by the compiler after enabling type checks. Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
f1e862c
to
d8bcc88
Compare
Introduce a new type helper
MixinTarget
allowing mixin functions to accept a type that describes public members of the target class only. This is working around the current TypeScript limitations:declaration: true
microsoft/TypeScript#17293private
members microsoft/TypeScript#36060Rework all existing mixins and the related documentation to use
MixinTarget<RealClass>
instead ofConstructor<any>
.Fix any errors discovered by the compiler after enabling type checks.
See also microsoft/TypeScript#38496
This PR depends on loopbackio/loopback-datasource-juggler#1839, the build will keep failing until a new version of juggler is released & loopback-next package locks are updated.Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈