chakra-ui-vue-next icon indicating copy to clipboard operation
chakra-ui-vue-next copied to clipboard

TS: Declare `chakra.element` types globally for factory function components.

Open codebender828 opened this issue 3 years ago • 0 comments

Feature request

Is your feature request related to a problem? Please describe.

It is currently unclear how to provide Typescript SFC support for Chakra factory components that will be auto imported. For JavaScript projects he seems to work fine however we may need to provide a solution for TS SFCs.

At the moment the solution is to declare a global namespace for Chakra UI Vue components.

In TypeScript declaration file

declare global {
  declare namespace chakra {
    import { chakra } from '@chakra-ui/vue-next'
    export const div: typeof chakra.div
  }
}

export {}

In SFC

<template>
  <chakra.div>value</chakra.div>
</template>

<script lang="ts" setup></script>

Describe the solution you'd like

Describe alternatives you've considered

Additional context

codebender828 avatar Dec 21 '21 11:12 codebender828