eclipsesource / eclipsesource/tabris-js

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

Open
#2,285 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
1.4k
Forks
171
PR merge metrics
No merged PRs in 30d

Description

### 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:

```ts
class CustomWidget extends Composite {
set height(value: number) { // 'height' is defined as a property in class 'Composite>', 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.