最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

typescript - Different type when it should be the same between a ref and a computed - Stack Overflow

programmeradmin1浏览0评论

In my Vue 3 project (3.5.13), I'm encountering an error that I don't understand.

const day = ref<DayPresenter>(new DayPresenter());
const dayComputed = computed<DayPresenter>(() => day.value);

I have an error “No overload matches this call.” on the computed. I also get a similar error when I pass it to a child component as props.

const props = defineProps({
  day: {
    type: Object as PropType<DayPresenter>,
    required: true,
  },
});

Why is there this error and what can I do to correct it?

I know I can cast by doing as DayPresenter but I'd like to avoid that.

发布评论

评论列表(0)

  1. 暂无评论