taro-ui icon indicating copy to clipboard operation
taro-ui copied to clipboard

在 VSCode、IntelliJ IDEA 等开发环境下,AtCurtain、AtNoticebar、AtList 等组件报类型错误,但可以正常预览、编译

Open loocor opened this issue 1 year ago • 4 comments

Taro UI 版本信息

v3.1.0-beta.3

问题描述

如题所诉,在 VSCode、IntelliJ IDEA 等开发环境下,AtCurtain、AtNoticebar、AtList 等组件报类型错误,但可以正常预览、编译。

部分组件,如 SwiperItem、AtGrid 可正常使用不报错

复现步骤

1、taro init 一路默认选项创建项目; 2、将 app.tsx 替换为以下 FC 入口; 3、用 VSCode 打开即可见上述 错误提示;

复现代码

// app.tsx

import 'default-passive-events'
import {useEffect, useState} from 'react'
import {useDidHide, useDidShow} from '@tarojs/taro'
import {AtCurtain} from "taro-ui";
import {View} from "@tarojs/components";
import './app.scss'

const App = (props) => {
  const [curtainShown, setCurtainShown] = useState<boolean>(false);

  useEffect(() => {
    setCurtainShown(true)
  }, [])

  useDidShow(() => {
  })

  useDidHide(() => {
  })

  return (
    <>
      <AtCurtain
        isOpened={curtainShown}
        closeBtnPosition='bottom'
        onClose={() => setCurtainShown(false)}
      >
        <View className='at-curtain__container curtain'>
        </View>
      </AtCurtain>
      {props.children}
    </>
  )
}

export default App

报错信息

各错误提示如下:

TS2322: Type '{ children: Element; current: number; index: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AtTabsPaneProps, any, any>> & Readonly<...>'.   Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AtTabsPaneProps, any, any>> & Readonly<...>'.

Type '{ children: string; marquee: true; speed: number; icon: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AtNoticeBarProps, any, any>> & Readonly<...>'.
  Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AtNoticeBarProps, any, any>> & Readonly<...>'.ts(2322)

Type '{ children: Element; isOpened: boolean; closeBtnPosition: "bottom"; onClose: () => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AtCurtainProps, any, any>> & Readonly<AtCurtainProps>'.
  Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AtCurtainProps, any, any>> & Readonly<AtCurtainProps>'.ts(2322)

系统信息

👽 Taro v3.5.2

  Taro CLI 3.5.2 environment info:
    System:
      OS: macOS 13.0
      Shell: 3.5.1 - /usr/local/bin/fish
    Binaries:
      Node: 18.7.0 - /usr/local/bin/node
      npm: 8.15.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.5.2 => 3.5.2
      @tarojs/components: 3.5.2 => 3.5.2
      @tarojs/helper: 3.5.2 => 3.5.2
      @tarojs/plugin-framework-react: 3.5.2 => 3.5.2
      @tarojs/plugin-platform-alipay: 3.5.2 => 3.5.2
      @tarojs/plugin-platform-jd: 3.5.2 => 3.5.2
      @tarojs/plugin-platform-qq: 3.5.2 => 3.5.2
      @tarojs/plugin-platform-swan: 3.5.2 => 3.5.2
      @tarojs/plugin-platform-tt: 3.5.2 => 3.5.2
      @tarojs/plugin-platform-weapp: 3.5.2 => 3.5.2
      @tarojs/react: 3.5.2 => 3.5.2
      @tarojs/router: 3.5.2 => 3.5.2
      @tarojs/runtime: 3.5.2 => 3.5.2
      @tarojs/shared: 3.5.2 => 3.5.2
      @tarojs/taro: 3.5.2 => 3.5.2
      @tarojs/taro-h5: 3.5.2 => 3.5.2
      babel-preset-taro: 3.5.2 => 3.5.2
      eslint-config-taro: 3.5.2 => 3.5.2
      react: ^18.0.0 => 18.2.0
      taro-ui: 3.1.0-beta.3 => 3.1.0-beta.3
    npmGlobalPackages:
      typescript: 3.7.5

补充信息

这里有个相似的问题 https://github.com/NervJS/taro-ui/issues/1497

loocor avatar Aug 10 '22 03:08 loocor

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

taro-ui-bot[bot] avatar Aug 10 '22 03:08 taro-ui-bot[bot]

找到问题原因了,就是组件下少了一个 children?: React.ReactNode; 属性

loocor avatar Aug 11 '22 02:08 loocor

此更新似乎还没有在 3.1.0-beta.4 上应用?

amehito avatar Nov 19 '22 19:11 amehito