Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS 4.x+: cannot override properties of Tabris widgets #2285

Open
cpetrov opened this issue Jan 18, 2024 · 0 comments
Open

TS 4.x+: cannot override properties of Tabris widgets #2285

cpetrov opened this issue Jan 18, 2024 · 0 comments
Labels

Comments

@cpetrov
Copy link
Member

cpetrov commented Jan 18, 2024

Problem description

Widget properties like e.g. left and height are exposed as class fields in the Tabris.js typings. However, at runtime, they are actually defined as accessors.

While it was possible to define property accessors in custom widgets that override Tabris.js widget properties in TypeScript 3.x, this does not work anymore since TypeScript 4.x. Since TypeScript 4.x, it is forbidden to override class fields using accessors (makes sense, because this does not work at runtime), which prevents customizing the behavior of Tabris.js properties in custom widgets:

class CustomWidget extends Composite {
  set height(value: number) { // 'height' is defined as a property in class 'Composite<Widget<any>>', but is overridden here in 'CustomWidget' as an accessor.ts(2611)
    super.height = value;
  }
  get height() {
    return super.height;
  }
}

Expected behavior

Tabris.js properties that are accessors at runtime should be defined as accessors in the typings as well.

Environment

  • Tabris.js version: 3.9.0
@cpetrov cpetrov added the bug label Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant