Skip to content

Resolve generic component setup context #871

Description

@m0ksem
<script lang="ts">
import { defineComponent, PropType, ref } from 'vue'

export default <T>() => defineComponent({
  props: {
    items: { type: Array as PropType<T[]>, required: true },
  },

  setup(props, { emit }) {
    const testVar= ref(0)

    return {
      testVar,
    }
  }
})
</script>

<template>
  <div>
     {{  testVar /* Cannot find name 'testVar'.ts(2304) */ }}
  </div>
</template>

Actually found out that this example not working (I'm using vite and vue-tsc). Is it possible to define a generic component at all?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions