unibest icon indicating copy to clipboard operation
unibest copied to clipboard

使用`<template></template>`标签报错,类型“IntrinsicElements”上不存在属性“template”

Open imleeou opened this issue 1 year ago • 8 comments

Bug report(问题描述)

我在使用unibest模版时,使用<template></template>标签时会标红,报错内容:【类型“IntrinsicElements”上不存在属性“template”。ts-plugin(2339)】

我的其他自己搭建的uniapp vue3 项目没有这个问题

Steps to reproduce(问题复现步骤)

  1. 使用pnpm create unibest my-project 创建项目
  2. [email protected]
  3. 快速创建,选择base[推荐]
  4. pnpm i 安装依赖,写一个标签 <template>123</template>

Screenshot or Gif(截图或动态图)

image

minimal reproduction(最小可还原代码)

按步骤创建就可复现

System Info

npx envinfo --system --npmPackages vue --binaries --browsers

执行上面命令,将结果贴下面

  System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 51.73 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
    Yarn: 1.22.19 - ~/Library/pnpm/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v18.20.2/bin/npm
    pnpm: 9.14.4 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 131.0.6778.86
    Safari: 18.0

imleeou avatar Nov 30 '24 12:11 imleeou

image same question

w3313003 avatar Nov 30 '24 14:11 w3313003

暂时添加配置后不飘红了

import Vue, { VNode } from 'vue'

declare global {
  namespace JSX {
    interface Element extends VNode {}
    interface ElementClass extends Vue {}
    interface IntrinsicElements {
      [elem: string]: any
    }
  }
}

w3313003 avatar Nov 30 '24 14:11 w3313003

重启一下vue扩展就可以,扩展的问题

skyeryg avatar Dec 05 '24 02:12 skyeryg

暂时添加配置后不飘红了

import Vue, { VNode } from 'vue'

declare global {
  namespace JSX {
    interface Element extends VNode {}
    interface ElementClass extends Vue {}
    interface IntrinsicElements {
      [elem: string]: any
    }
  }
}

在哪里配置

luniard avatar Dec 05 '24 03:12 luniard

解决了嘛同样的问题

wuhao1477 avatar Dec 09 '24 05:12 wuhao1477

解决了

修改tsconfig.json文件

{
  "compilerOptions": {
    "composite": true,
    "skipLibCheck": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "noImplicitThis": true,
    "allowSyntheticDefaultImports": true,
    "allowJs": true,
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"],
      "#/*": ["./src/types/*"]
    },
    "outDir": "dist",
    "lib": ["esnext", "dom"],
    "types": [
      "@dcloudio/types",
      "@uni-helper/uni-types",
      "@types/wechat-miniprogram",
      "wot-design-uni/global.d.ts",
+      "vue/jsx" // 添加这一行
    ]
  },
  // ... orther config
 }

wuhao1477 avatar Dec 09 '24 06:12 wuhao1477

现在vue的volar被收编了,是officical插件。重启了还是报错。我推测可能是eslint规则问题,我的ts配置jsx相关类型支持都开了。

CherishMvp avatar Dec 17 '24 07:12 CherishMvp

vue official 使用 2.1.10 可以

feige996 avatar Jan 06 '25 13:01 feige996