software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.05k stars 1.31k forks source link

Type annotations are not supported in __workletClass #6642

Open wcandillon opened 2 weeks ago

wcandillon commented 2 weeks ago

Description

A class that has the __workletClass annotation doesn't support any kind of type annotations. The following works:

class Test {
  __workletClass = true;
  value;

  constructor(value) {
    this.value = value;
  }
}

But the following wouldn't:

class Test {
  __workletClass = true;
  value: number;

  constructor(value: number) {
    this.value = value;
  }
}

or

class Test<T> {
  __workletClass = true;
  value: T;

  constructor(value: T) {
    this.value = value;
  }
}

Steps to reproduce

Add a type annotation to a class that has the __workletClass property. Adding a type annotations to https://github.com/software-mansion/react-native-reanimated/blob/main/apps/common-app/src/examples/RuntimeTests/tests/plugin/fileWorkletization.ts should be enough to reproduce the issue.

Snack or a link to a repository

https://github.com/shopify/react-native-skia

Reanimated version

3.5.1

React Native version

0.75.2

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Debug app & dev bundle

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 2 weeks ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

tomekzaw commented 2 weeks ago

cc @tjzel Can you please take a look?

wcandillon commented 2 weeks ago

Adding a type annotations to https://github.com/software-mansion/react-native-reanimated/blob/main/apps/common-app/src/examples/RuntimeTests/tests/plugin/fileWorkletization.ts should be enough to reproduce the issue.

NiuGuohui commented 4 days ago

@tjzel Another problem is that it does not support the use of implements and extends keywords on class declarations