Open boris-petrov opened 1 year ago
Whoops, this one is quite straightforward and I missed it while doing the work for 5.1.1. Should be fixed by #20492.
Thanks for the release! However, even with 5.1.2 I get the same error. The init
method comes from node_modules/ember-source/types/stable/@ember/object/core.d.ts:114
. There is a comment on that noting:
NOTE: If you do override `init` for a framework class like `Component`
from `@ember/component`, be sure to call `this._super(...arguments)`
in your `init` declaration!
If you don't, Ember may not have an opportunity to
do important setup work, and you'll see strange behavior in your
application.
So I'm not sure whether we really need to pass ...arguments
or not... I was under the impression that this is not needed? Is this some old comment or it's still true?
I pushed another commit to the reproduction repo. It simply does:
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
public override init(): void {
super.init();
}
}
That causes an error. That is, super.init()
in components now works fine but in controllers (and routes, and services, and classes that simply extend EmberObject
) doesn't. The error is:
app/controllers/application.ts:5:11 - error TS2554: Expected 1 arguments, but got 0.
5 super.init();
~~~~~~
node_modules/ember-source/types/stable/@ember/object/core.d.ts:114:10
114 init(_properties: object | undefined): void;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An argument for '_properties' was not provided.
Will take a gander sometime this week or next to try to get this resolved. Thanks for the follow-up!
🐞 Describe the Bug
init
in classic components used to not accept any arguments andsuper.init()
could be called like that. Since 5.1.0, this no longer works. I believe this is a bug.🔬 Minimal Reproduction
Repo.
Run
npm install
and then./node_modules/.bin/tsc
.😕 Actual Behavior
Type error on
super.init()
.🤔 Expected Behavior
No error. Removing the last commit (which upgrades Ember) and rerunning
npm install
and thentsc
will remove the errors.🌍 Environment
cc @chriskrycho