Reactive properties in TypeScript #25
-
Beta Was this translation helpful? Give feedback.
Answered by
sergejcodes
Mar 6, 2022
Replies: 1 comment 1 reply
-
All reactive properties are created dynamically, that's why TypeScript doesn't know their types. You have to explicitly define the types in a separate interface (that is exported with the same name as the component class). The docs have a more detailed example. In your case it should look like this: import Minze, { EventListeners, MinzeElement, Reactive } from "minze"
export interface CounterClick {
count: number
}
export class CounterClick extends MinzeElement {
reactive: Reactive = [
['count',0]
]
// ...
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
zuramai
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All reactive properties are created dynamically, that's why TypeScript doesn't know their types. You have to explicitly define the types in a separate interface (that is exported with the same name as the component class). The docs have a more detailed example.
In your case it should look like this: