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

fix: add generic props type for NodeData #330

Open
wants to merge 1 commit into
base: v0.1.x
Choose a base branch
from

Conversation

kkshyu
Copy link

@kkshyu kkshyu commented Oct 8, 2021

in typescript, we suppose not to use any. we can simply add the generic type on Node to make codes better.
ex.

  const {
    actions: { setProp },
    props,
  } = useNode((node: Node<CraftProgramCollectionProps>) => ({
    props: node.data.props,
  }))

setProps will be:

const setProp: (cb: (props: CraftProgramCollectionProps) => void, throttleRate?: number | undefined) => void

in typescript, we suppose not to use `any`. we can simply add the generic type on Node to make codes better.
ex.
```ts
  const {
    actions: { setProp },
    props,
  } = useNode((node: Node<CraftProgramCollectionProps>) => ({
    props: node.data.props,
  }))
```
`setProps` will be:
```
const setProp: (cb: (props: CraftProgramCollectionProps) => void, throttleRate?: number | undefined) => void
```
@kkshyu kkshyu requested a review from prevwong as a code owner October 8, 2021 20:28
@netlify
Copy link

netlify bot commented Oct 8, 2021

✔️ Deploy Preview for craftjs ready!

🔨 Explore the source changes: c23d863

🔍 Inspect the deploy log: https://app.netlify.com/sites/craftjs/deploys/6160a9dc225b94000830aec2

😎 Browse the preview: https://deploy-preview-330--craftjs.netlify.app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant