Skip to content

Reactive properties in TypeScript #25

Answered by sergejcodes
zuramai asked this question in Q&A
Discussion options

You must be logged in to vote

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]
  ]
  
  // ...
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zuramai
Comment options

Answer selected by zuramai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants