Bug: Cannot use spread with the injector (Injection With Inheritance in Aurelia)
See original GitHub issueI’m submitting a bug report
- Library Version:
1.4.1
(Webpack build uses
native-modules
dist)
Please tell us about your environment:
-
Operating System: Windows 10
-
Node Version: v8.11.1
-
Yarn Version: 1.5.1
-
Webpack Version Webpack 4.16.5
-
Browser: Chrome
-
Language: TypeScript 3.0.1
Current behavior: Using the spread operator doesn’t work as per the blog post here with TypeScript, for some reason it seems to generate an additional empty object parameter?
I also have to make each property optional on the base class, which isn’t ideal but workable.
https://ilikekillnerds.com/2016/11/injection-inheritance-aurelia/
import { autoinject, containerless } from 'aurelia-framework';
import { I18N } from 'aurelia-i18n';
@autoinject
@containerless
export abstract class BaseDialog {
constructor(
protected readonly controller?: DialogController,
protected readonly element?: Element,
) {
}
}
@autoinject
export class NotesDialog extends BaseDialog {
constructor(
protected readonly i18n: I18N,
protected readonly dialogUtils: DialogUtils,
...rest
) {
super(...rest);
// rest[0] = {}; <- Why is this empty object here?
// rest[1] = DialogController
// rest[2] = Element;
console.warn('NotesDialog', rest);
}
}
Additionally, if I console.log the “NotesDialog.inject” static property at run-time, I get:
0: ƒ I18N(ea, signaler)
1: ƒ DialogUtils(dialogService, i18n)
2: ƒ Object()
Expected/desired behavior: I’d expect to be able to use the “…rest” pattern so I don’t need to update each subclass if I update the dependencies on the base class.
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (19 by maintainers)
Released on NPM 😃 Thanks for helping out!
I’ll attempt to get it out this evening.