Subscribe on changes!

Use interface prop return type is any

avatar
Jul 3rd 2021

Version

3.1.4

Reproduction link

Steps to reproduce

import { defineComponent } from 'vue';

interface Prop {
  icon: string;
}

export default defineComponent({
  props: ['icon'],
  setup(props: Prop) {
    return () => (
      <div>
        <button />
      </div>
    );
  },
});

image

What is expected?

What is actually happening?

avatar
Jul 3rd 2021

typing setup's argument doesn't type the external Prop interface of the component.

import { defineComponent, PropType } from 'vue';

export default defineComponent({
  props: {
    icon: String // as PropType<'home' | 'user' | 'edit'>
  },
  setup(props) {
    return () => (
      <div>
        <button />
      </div>
    );
  },
});