[New release] Au v2 beta 20

Happy Sunday/Monday folks!

Beta 20 has finally arrived https://github.com/aurelia/aurelia/releases/tag/v2.0.0-beta.20

Please help try it out and create issues for any bugs/unexpected behaviors you run into. Also come join the discussion here or on Discord thread for beta 20

Previous releases discourses:


2.0.0-beta.20 (2024-07-07)

BREAKING CHANGES:

  • router-lite: can* hook semantics by @Sayan751 (#2002) (ac5359f)
    canLoad/canUnload hooks now only treat false as false.
    Previously canLoad and canUnload only consider true as can do, means if a routing component has either the hook canLoad/canUnload,
    those hooks must return true to load/unload. This is not consistent with the rest of the frameowrk, and generally will be easier to miss during refactoring.
  • router: navigation coordinator refactor by @jwx (#1997) (1b97340)
    canLoad/canUnload hooks now only treat false as false.
    Moves responsibilities and recursive code from routing scope to iterative code in navigation coordinator.
    Refresh and browser back and forward now behave the same way deep links does; if a viewport with a default component/route has been emptied/cleared the mentioned browser actions will now load the default (instead of keeping the viewport empty).
  • tooling: bindable inheritance (bb1fe26)
    When generating types for .html file with convention, bindables export will be a record, instead of array now.
    Applications migrating from beta.15-beta.19 will need to change the types for .html modules in resource.d.ts like the following example:
    ...
    export const bindables: Record<string, Partial<BindableDefinition>>
    ...
    
    or if it doesn’t matter to your applications, simple having
    ...
    export const bindables: Record<string, any>
    ...
    
    will also work.
  • metadata: metadata is defined on the immediate target class, instead of first available metadata source (i.e inherited from parent) by @Sayan751 (#1992) (bb1fe26)

Bug Fixes:

Refactorings:

  • validation: state rule using record to declare messages by @Sayan751 (9df93e0)
12 Likes

Thanks for timely updates!

Thanks for the update guys! Looking forward to testing it.

Hello,
I’ve just made a new webpack project. Added only @bindable firstName = '' ; in MyApp class and got the error bellow:

  TS1270: Decorator function return type '(target: unknown, context: ClassDecoratorContext<abstract new (...args: any) => any> | ClassFieldDecoratorContext<unknown, unknown> | ClassGetterDecoratorContext<unknown, unknown>) => void' is not assignable to type 'void | ((this: MyApp, value: string) => string)'.

Type ‘(target: unknown, context: ClassDecoratorContext<abstract new (…args: any) => any> | ClassFieldDecoratorContext<unknown, unknown> | ClassGetterDecoratorContext<unknown, unknown>) => void’ is not assignable to type ‘(this: MyApp, value: string) => string’.
Target signature provides too few arguments. Expected 2 or more, but got 1.

@bindable() firstName = ''

This is typescript 5.5 doing, it’s trying to be too smart and “over-infer” the typing for the 2 parameter in the decorator usage. I’m not sure what to do to fix this issue yet.

To fix this, you can change typescript version to 5.4.x

cc @huochunpeng @Sayan751

Suffered from that myself and at the moment the only (and relatively easy) solution I came up with is moving the

export declare function bindable(_: undefined, context: ClassFieldDecoratorContext): void;

declaration on top of the others. Made a patch with patch-package and it is convenient enough for the time being.

@bigopon It seems that stricter type-checking for decorators is introduced here: Report grammar errors for invalid decorator grammar by rbuckton · Pull Request #57749 · microsoft/TypeScript · GitHub. However, the problem might simply be caused by how TS resolved the method signatures. Considering a method signature with more arguments is more restrictive than the one with fewer arguments, it makes sense when they precede the less-specific ones. Thanks @sarp for drawing attention to that. I’ll push a change for that.