- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
所以我构建了一个 spfx webpart,其中一个功能是显示链接预览。我用了this library为了任务。我必须更改包“styled-components”的版本并更新我的“react”(16.4.18) 和“react-dom”(16.0.9) 才能正常工作。进行这些更改并运行 gulp build
后,我收到以下错误列表:
[10:21:13] [tsc] typescript version: 2.4.2
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(27,38): error TS1005: '=' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(29,46): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(29,75): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(29,99): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,54): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,78): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,81): error TS1109: Expression expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,97): error TS1109: Expression expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,122): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,130): error TS1128: Declaration or statement expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(31,138): error TS1005: ',' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(44,48): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(44,49): error TS1109: Expression expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(44,50): error TS1109: Expression expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(44,68): error TS1005: '(' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(44,69): error TS1005: ')' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(46,30): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(46,54): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/prop-types/index.d.ts(46,57): error TS1109: Expression expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2297,27): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2298,14): error TS1005: ':' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2298,28): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2299,9): error TS1109: Expression expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2300,9): error TS1005: '(' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2301,9): error TS1005: '(' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2302,5): error TS1005: '(' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2302,12): error TS1005: ')' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2314,49): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2314,76): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2314,99): error TS1005: ';' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2315,13): error TS1128: Declaration or statement expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2316,13): error TS1005: '(' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2316,17): error TS1005: ',' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2316,44): error TS1005: ',' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2316,45): error TS1005: ':' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2318,17): error TS1005: '(' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2318,21): error TS1005: ',' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2318,51): error TS1005: ',' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2318,52): error TS1005: ':' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2320,21): error TS1005: '(' expected.
[10:21:17] Error - [tsc] node_modules/@types/react/index.d.ts(2320,24): error TS1005: ')' expected.
[10:21:17] Error - 'tsc' sub task errored after 3.75 s
exited with code 2
this github issue与我的有点相似,建议我将我的 typescript 版本更新到2.3.4或更高版本。
还有一个我目前找不到的 github 问题,建议将 typescript 版本更新到 2.8.x 或更高版本。
我的 typescript 版本是 3.1.3。我在本地(在项目的 Node 模块文件夹中)和全局安装了相同的版本。您可能已经注意到,在构建开始时我会得到输出
[tsc] typescript version: 2.4.2
我已经将“package.json”文件中与 typescript 相关的所有条目以及 yarn.lock 文件(我使用的是 yarn)更改为最初的“3.1.3”或“~3.1.3”说“2.4.1”或“2.4.2”或“~2.4.1”或“~2.4.2”。从我读到的内容来看,它与定义/声明语法相关,仅在 typescript 2.8 及更高版本中受支持。例如,有问题的行之一是:
Error - [tsc] node_modules/@types/prop-types/index.d.ts(27,38): error TS1005: '=' expected.
export const nominalTypeHack: unique symbol;
一般来说,我对 typescript 和 node 还很陌生,所以这可能是导致我不知道如何解决这个问题的另一点。
如果需要提供更多信息,我将很乐意提供。预先感谢所有建议和答案。
最佳答案
我做了一个快速 web search并发现了几个线程(例如 1、2)表明 SPFx 构建系统将人们固定在旧版本的 TypeScript 上。我没有看到解决方案。
一种可能的方法是将您的代码分成与 React 交互的部分和与 SPFx 交互的部分,使用最新版本的 tsc
自行将第一部分编译为 JavaScript,并包含通过 SPFx 构建系统编译第二部分时生成的 JavaScript 文件。我对 SPFx 构建系统一无所知,不知道这是否可行;如果您尝试并遇到特定问题,我可能会提供帮助。
另一个想法是使用与您的 TypeScript 版本兼容的旧版本 @types
包,尽管它们可能缺少您需要的功能。例如,对于 TypeScript 2.4.2,您可以通过运行 npm install @types/prop- 安装
(或 @types/prop-types
的 ts2.4
标签types@ts2.4npm install -D @types/prop-types@ts2.4
;有关差异的详细信息,请参阅 here)。
关于node.js - SPFx Webpart - node_modules/@types/[prop types] 和 [react] index.d.ts : loads of "error TS1005" on gulp build,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52925657/
我仍在学习如何将 API 数据与 react 和 nextjs 一起使用。但是,为什么我的函数只在我编写 {props.props.title} 而不是我期望的 {props.title} 时起作用?
我仍在学习如何将 API 数据与 react 和 nextjs 一起使用。但是,为什么我的函数只在我编写 {props.props.title} 而不是我期望的 {props.title} 时起作用?
我正在用 TypeScript 构建一个 React 应用程序。我有一个 RequiresPermission基于谓词的组件应该渲染一个或另一个组件并转发所有 Prop 。 type Props =
我想通过 gatsby 布局传递我所有的 props。例如: import React, { Component } from 'react'; export default class Exampl
如果我使用合成属性,那我为什么不直接说: self.property = nil; 这将释放引用计数,并确保我没有悬挂指针。 看起来很简单,但我看到的 99% 的代码似乎都是这样做的: [proper
Eslint 抛出 eslint(react/prop-types) 错误,尽管已经声明了 propTypes。我正在使用 eslint-plugin-react 我研究了其他几个类似的问题以及 li
我正在使用以下由 linter eslint-plugin-react 解析的代码。它返回警告: "product is missing in props validation" 当我在底部的 pro
我正在尝试在 React 应用程序中添加 TypeScript。 版本: "react": "16.9.0", "typescript": "3.5.3", 我有一个像这样的数组 import aLo
我有一个组件 . 如果组件没有 this.props.children , 我想设置 Prop ariaLabel作为isRequired ,否则 in 可以是可选的。我该怎么做? ariaLabe
我应该用一个代替另一个吗?一起使用它们更好吗?谢谢。 最佳答案 prop in obj 检查 obj 是否有名为 prop 的属性,即使它只是从原型(prototype)继承而来。 obj.hasOw
我的组件 Text有 2 个 Prop :isHideable: boolean和 hidden: boolean .我如何允许 Hidden仅在 isHideable 时作为 Prop 是true
我试图将带有一些 Prop 的功能组件发送到另一个组件,并在接收组件中尝试键入检查该组件的某些 Prop 。这是代码: // BaseButton.tsx export type ButtonProp
是否可以从也作为 prop 传递的未知组件推断出正确的 props 类型? 如果已知组件(存在于当前文件中),我可以获得 Prop : type ButtonProps = React.Compone
我对 react 还很陌生,这是我正在努力解决的问题。 有一个父组件 家长 它将 Prop 传递给 child 。 其中一个 Prop ,包括一个要渲染的元素,如下所示: 在子组件中,我想获取这个组
我想做一个 Tabs推断 active 的可能值的组件prop 基于它的 child 拥有的东西 name Prop 。这就是我尝试这样做的方式: import React from 'react'
我对 react 还很陌生,并且只有当用户开始向下滚动时,我才尝试将更多信息加载到记录数组中。问题是新信息出现在数组中,但如果您尝试调用它,它将返回undefined。我在这里不明白什么? 父组件:
因此,如果我对一个组件有很多不同的 Prop ,我希望我可以做类似的事情 const { ...props } = props; 而不是 const { prop1, prop2, prop3, ..
这是我寻求指导的问题类型,因为我不确定我正在寻找的内容是否存在...... 上下文:我正在使用 Firestore 来保存数据,并且正在构建一个可重用的自定义 Hook (React 16.8),以便
我有一个 React 组件,它获取一个配置对象作为 prop,它看起来像这样: { active: true, foo: { bar: 'baz' } } 在
如何附加另一个属性?我有一个 react 组件,其中有人传入 ...props,我想附加一个额外的 Prop 最佳答案 请记住,传递 Prop 的顺序将决定将哪个值传递给该组件。这适用于有两个同名
我是一名优秀的程序员,十分优秀!