With the release of Aurelia 2 Beta 15, there are some important changes to be aware of regarding decorators. This update brings Aurelia 2 into compliance with the Stage 4 TC39 decorators proposal, resulting in significant differences in how decorators work compared to previous versions.
One notable change is that inline decorators for injection on constructors are no longer supported. For example, the following syntax is no longer valid:
constructor(@IApi readonly api: IApi, @IRouter private router: IRouter) { }
Instead, to handle injection, you can define a class property and use the resolve
function from the aurelia
package. Here’s an example:
readonly api = resolve(IApi);
Make sure to import the resolve
function from the aurelia
package at the top of your file.
Another important note for TypeScript users: remove the following lines from your tsconfig.json
file:
"emitDecoratorMetadata": true, "experimentalDecorators": true,
These settings are no longer necessary with the updated decorator implementation in Aurelia 2 Beta 15.
Your writing is a true testament to your expertise and dedication to your craft. I’m continually impressed by the depth of your knowledge and the clarity of your explanations. Keep up the phenomenal work!