You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The afterLoad method is confusingly not called with a this context of the controller constructor but is instead undefined.
TypeScript is advising that this will be the controller constructor but at runtime it is failing.
Steps to reproduce
Create a controller
exportclassLoaderControllerextendsController{staticvalues={durationSeconds: {type: Number,default: 30},};staticafterLoad(identifier: string,application: Application){const{ controllerAttribute }=application.schema;console.log('afterLoad test',this);// this is undefinedconsole.log('afterLoad stuff',{identifier, controllerAttribute });console.assert(this.values.durationSeconds.default,30);// errors as this is undefined}}
Expect that the this will be the controller constructor. Instead it is undefined.
Problem
The afterLoad method is confusingly not called with a
this
context of the controller constructor but is instead undefined.TypeScript is advising that
this
will be the controller constructor but at runtime it is failing.Steps to reproduce
Create a controller
Expect that the
this
will be the controller constructor. Instead it is undefined.Potential solution
stimulus/src/core/router.ts
Line 58 in 8217e9b
The text was updated successfully, but these errors were encountered: