language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

use tsx error(使用 tsx 页面报错)

Open beixiyo opened this issue 2 months ago • 6 comments

Vue - Official:Version: v2.0.10 (is vscode latest) Vscode - Version: 1.88.0(is vscode latest)

i am not use Prettier | ESLint | OtherVSCodeVueExtension
我没有使用任何无关插件


vite.config.ts

import vueJsx from '@vitejs/plugin-vue-jsx'

export default defineConfig({
    plugins: [
        vue(),
        vueJsx(),
    ]
})

ErrorFile.vue (报错的文件内容)

<script setup lang="tsx">
function Splitor() {
   /**  运算符“>”不能应用于类型“string”和“RegExp”。ts-plugin(2365) */
    return (<span style="margin: 0px 7px">/</span>)
}
</script>

beixiyo avatar Apr 25 '24 08:04 beixiyo

Vue - Official:Version: v2.0.10 (is vscode latest) Vscode - Version: 1.88.0(is vscode latest)

i am not use Prettier | ESLint | OtherVSCodeVueExtension
我没有使用任何无关插件

beixiyo avatar Apr 25 '24 08:04 beixiyo

I'm able to reproduce this issue with the following steps:

  1. Create a new file (not sure why an existing file doesn't report this error)
  2. Paste the code image

BTW you have two <script setup> tags but the first one doesn't have an end tag.

so1ve avatar Apr 25 '24 08:04 so1ve

我在项目试了下,好像没问题, image "vue": "^3.2.47", "@vitejs/plugin-vue-jsx": "^3.0.0",

nsnans avatar Apr 26 '24 02:04 nsnans

我在项目试了下,好像没问题, image "vue": "^3.2.47", "@vitejs/plugin-vue-jsx": "^3.0.0",

image

{
    "vue": "^3.4.24",
    "vite": "^5.2.8",
    "@vitejs/plugin-vue-jsx": "^3.1.0",
    "Vue - Official": "v2.0.10",
    "VSCode": "1.88.0"
}

beixiyo avatar Apr 26 '24 03:04 beixiyo

我在项目试了下,好像没问题, image "vue": "^3.2.47", "@vitejs/plugin-vue-jsx": "^3.0.0",

image

{
    "vue": "^3.4.24",
    "vite": "^5.2.8",
    "@vitejs/plugin-vue-jsx": "^3.1.0",
    "Vue - Official": "v2.0.10",
    "VSCode": "1.88.0"
}

新建了个项目,一样版本,没问题,可能是其他拓展引起的。为什么不直接使用tsx文件写呢?感觉vue文件里面写好麻烦,导出函数什么的还会报错,我项目就是全部tsx写

nsnans avatar Apr 26 '24 03:04 nsnans

我在项目试了下,好像没问题, image "vue": "^3.2.47", "@vitejs/plugin-vue-jsx": "^3.0.0",

image

{
    "vue": "^3.4.24",
    "vite": "^5.2.8",
    "@vitejs/plugin-vue-jsx": "^3.1.0",
    "Vue - Official": "v2.0.10",
    "VSCode": "1.88.0"
}

新建了个项目,一样版本,没问题,可能是其他拓展引起的。为什么不直接使用tsx文件写呢?感觉vue文件里面写好麻烦,导出函数什么的还会报错,我项目就是全部tsx写

image 禁用所有扩展也一样,vue 里写 tsx 仅仅是因为复用小的代码片段。写多了哪有 vue 可读性高

beixiyo avatar Apr 26 '24 03:04 beixiyo