Skip to content

Resolve generic component setup context #871

Closed
@m0ksem

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?

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