打字稿错误:类型中缺少属性“ children”,但在“ CommonProps”类型中必需

JD填充

第一次遇到这样的错误,请耐心等待。

我正在一个项目上,并打开一个文件进行更改。我打开了文件,实际上没有进行任何更改,只是使用Prettier格式化了文件。

格式化后,该项目将以下错误抛出:

TypeScript error in C:/Users/name/source/repos/UsedEquipment/src/pages/listings/sections/SearchResultListings.tsx(253,16):
Type '{ style: { height: string; }; type: "rect"; ready: false; showLoadingAnimation: true; }' is not assignable to type '(IntrinsicAttributes & CommonProps & { color?: string | undefined; rows?: number | undefined; showLoadingAnimation?: boolean | undefined; customPlaceholder?: undefined; } & Pick<...> & { ...; } & { ...; }) | ... 4 more ... | (IntrinsicAttributes & ... 2 more ... & { ...; })'.
  Property 'children' is missing in type '{ style: { height: string; }; type: "rect"; ready: false; showLoadingAnimation: true; }' but required in type 'CommonProps'.  TS2322

这是引发错误的代码:

showPlaceholders() {
    let items: Object[] = [];
    for (let i = 0; i < ITEMSPERPAGE; i++) {
      //show # of placeholders
      items.push(
        <div
          className="productwrap col-xs-12 col-sm-4 col-md-4 col-lg-3 placeholder"
          key={i}
        >
          <div className="product-wrapper">
            <div className="product-image">
              <ReactPlaceholder
              ^ Error thrown here
                style={{ height: "180px" }}
                type="rect"
                ready={false}
                showLoadingAnimation={true}
              ></ReactPlaceholder>
            </div>
            <div className="product-info-column">
              <ReactPlaceholder
              ^ Error thrown here
                type="text"
                rows={6}
                ready={false}
                showLoadingAnimation={true}
              ></ReactPlaceholder>
            </div>
          </div>
        </div>
      );
    }
    return items;
  }

我不确定此错误的含义或解决方法。任何的想法?

马希因-拉蒙

React Placeholder需要一个子组件传入其中的任何有效html标记。

<ReactPlaceholder { /*...your other optional props */ }>
  <MyComponent /> {/* this is mandatory */ }
</ReactPlaceholder>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

“系列”类型中缺少属性“帖子”,但在“{...}”类型中是必需的

打字稿错误:类型“{}”中缺少属性“mapType”

打字稿“类型中缺少属性”,但类型为“从不”

类型'{image:string;类型中缺少属性'children';数量:}”,但在“ BannerLayer”类型中为必填项。TS2741

反应导航和打字稿。类型中缺少属性“getScreen”

打字稿 | 通用可索引类型中缺少属性

打字稿:类型中缺少索引签名

打字稿/角度2:类型缺少属性

打字稿条件类型缺少属性

打字稿错误:数字 [] 中缺少属性“0”

TypeScript属性'navigation'在类型中缺失,但在'Props'类型中是必需的React Native

从接口到递归类型的打字稿转换引发类型错误中缺少索引签名

如何修复打字稿NodeJ中的eslint错误:“函数中缺少返回类型”

Jest spyOn无法与打字稿一起使用:“类型'Spy'中缺少属性'mockRestore'”

类型“ {}”中缺少属性“ submitAction”,但类型中必需

类型“ {}”中缺少属性“ className”,但类型“ IProps”中则必需

复杂类型对象中可选属性的打字稿类型

流星打字稿抱怨vscode中缺少文档类型

打字稿:扩展接口时类型中缺少索引签名

类型“{ searchValue: string;”中缺少属性“value” setSearchValue: Dispatch<SetStateAction<string>>; }' 但在'Props'类型中需要

类型错误:无法分配给打字稿中对象“[object Array]”的只读属性“0”

打字稿错误:量角器中的“未知”类型不存在“清除”或“发送”属性

类型错误:无法在打字稿中读取未定义、reactjs 的属性“map”

打字稿中的 Axios 类型

打字稿中的对象类型

数组中的打字稿类型

打字稿中的全局类型

打字稿中的“复合类型”

打字稿中的类型分配