3

这两天在用 vue3+typescript 重构一个 vue2 项目,但是 props 的类型检查真的好弱...

 3 years ago
source link: https://www.v2ex.com/t/791413
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  程序员

这两天在用 vue3+typescript 重构一个 vue2 项目,但是 props 的类型检查真的好弱...

  Smash · 23 小时 39 分钟前 · 1809 次点击

说是重构,基本上算是重写了.不过由于用了 tailwindcss,还好都只是写了些静态页面.

今天正准备开始写逻辑,最后这 typescript 的支持程度,我真的是写不下去了.

今天准备赶紧切换到 react.

无意引战!!!

无意引战!!!

无意引战!!!

只是我没搞懂为什么 vue3 对 typescript 的支持这么差...

例如下面的写法,关于 props 类型检查,这种写法我看着真的蛋疼.

export default defineComponent({
    props: {
        message: {
            type: Object as PropType<FlashInterface>,
            required: true
        }
    },
    setup(props) {
            // Stuff
        }
});

后来我又想了想,可能是因为.vue 模板的原因导致的,因为在<template>模板里面 this.$emit 都要被 vscode 红线报错.

所以,如果要愉快的使用 vue3,我觉得 vue3+js 可能才是最好的选择.

还有,我是业余前端,以上观点请轻喷.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK