Ant-design: TS2304:找不到名称“PropertyKey”。

创建于 2017-07-18  ·  3评论  ·  资料来源: ant-design/ant-design

版本

2.12.1

环境

macOS 10.12.3

转载链接

https://github.com/tylerlong/react-antd-ts-test

重现步骤

git 克隆https://github.com/tylerlong/react-antd-ts-test

纱线安装

纱线构建

什么是预期?

它应该没有问题

实际发生了什么?

➜ ts-test git:(master) ✗ 纱线构建
纱线构建 v0.22.0
$ webpack

[在装载机]使用[email protected]从打字稿和从/Users/tylerlong/src/react/ts-test/tsconfig.json“tsconfig.json”。

[at-loader] 在单独的进程中开始检查...

[at-loader] 检查完成,有 2 个错误
哈希:c0b8bc6cbb418f703794
版本:webpack 3.3.0
时间:11342ms
资产大小块块名称
bundle.js 3.67 MB 0 [emitted] [big] main
bundle.js.map 3.83 MB 0 [emitted] main
[28] (webpack)/buildin/global.js 509 字节 {0} [内置]
[120] (webpack)/buildin/module.js 517 字节 {0} [内置]
[396] ./src/index.tsx 334 字节 {0} [内置]
[503] ./node_modules/moment/locale ^.\/.*$ 2.79 kB {0} [可选] [内置]
[790] (webpack)/buildin/amd-options.js 82 字节 {0} [内置]
909个隐藏模块

[at-loader] 中的错误 ./node_modules/antd/lib/table/Table.d.ts:109:27
TS2304:找不到名称“PropertyKey”。

[at-loader] 中的错误 ./node_modules/antd/lib/table/Table.d.ts:112:33
TS2304:找不到名称“PropertyKey”。
错误 命令失败,退出代码 2。


演示项目是根据https://www.typescriptlang.org/docs/handbook/react-&-webpack.html创建的

我在尝试将 antd 添加到项目时遇到了问题。

最有用的评论

因为PropertyKeyes2015库中,所以你应该在编译中包含es2015 ,在tsconfig.json添加lib选项。

        "lib": [
            "es5",
            "dom",
            "dom.iterable",
            "es2015"
        ]

所有3条评论

因为PropertyKeyes2015库中,所以你应该在编译中包含es2015 ,在tsconfig.json添加lib选项。

        "lib": [
            "es5",
            "dom",
            "dom.iterable",
            "es2015"
        ]

有用! 谢谢

添加以下内容就足够了:

"lib": [
            "dom",
            "es2015"
        ],

我有同样的问题。
版本 2.13.0
添加后:
"lib": [ "dom", "es2015" ],
我有很多错误:

错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(22,4): 错误 TS2687: 'val 的所有声明
ue' 必须具有相同的修饰符。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(45,4):错误 TS2687:'siz 的所有声明
e' 必须具有相同的修饰符。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(51,4):错误 TS2687:'pro 的所有声明
totype' 必须具有相同的修饰符。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(65,4):错误 TS2687:'siz 的所有声明
e' 必须具有相同的修饰符。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(71,4):错误 TS2687:'pro 的所有声明
totype' 必须具有相同的修饰符。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(76,10): 错误 TS2428: 'We 的所有声明
akMap' 必须具有相同的类型参数。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(85,26):错误 TS2344:类型“K”不满足
fy 约束“对象”。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(86,55):错误 TS2344:类型“K”不满足
fy 约束“对象”。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(87,4): 错误 TS2403: 后续变量 decl
arations 必须具有相同的类型。 变量“原型”必须是“WeakMap”类型',但这里有类型 'WeakMap ny, any>'。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(87,4):错误 TS2687:'pro 的所有声明
totype' 必须具有相同的修饰符。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(102,4): 错误 TS2403: 后续变量 dec
larations 必须具有相同的类型。 ',但这里有类型 'WeakSet'
.
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-collections\index.d.ts(102,4):错误 TS2687:'pr 的所有声明
ototype' 必须具有相同的修饰符。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-promise\index.d.ts(10,14): 错误 TS2300: 重复标识符 'Promi
瑟'。
[10:20:42] 错误 - 打字稿 - node_modules\@types\es6-promise\index.d.ts(41,18): 错误 TS2300: 重复标识符 'Promi
瑟'。
[10:20:42] 错误 - 打字稿 - node_modules\@types\lodash\index.d.ts(19448,14):错误 TS2428:'WeakMap' 的所有声明
必须具有相同的类型参数。
[10:20:42] 错误 - 打字稿 - node_modules\typescriptlib.es2015.collection.d.ts(44,10): 错误 TS2428: 所有声明
'WeakMap' 的 s 必须具有相同的类型参数。
[10:20:42] 错误 - 打字稿 - node_modules\typescriptlib.es2015.iterable.d.ts(156,10): 错误 TS2428: 所有声明
'WeakMap' 必须具有相同的类型参数。
[10:20:42] 错误 - 打字稿 - node_modules\typescriptlib.es2015.iterable.d.ts(210,10): 错误 TS2300: 重复标识
火热的'承诺'。
[10:20:42] 错误 - 打字稿 - node_modules\typescriptlib.es2015.promise.d.ts(222,12): 错误 TS2300: 重复标识符
更“承诺”。
[10:20:42] 错误 - 打字稿 - node_modules\typescriptlib.es2015.symbol.wellknown.d.ts(132,10): 错误 TS2428: 所有声明
'WeakMap' 的参数必须具有相同的类型参数。
[10:20:42] 错误 - 打字稿 - node_modules\typescriptliblib.es2015.symbol.wellknown.d.ts(167,10): 错误 TS2300: Duplicat
e 标识符“承诺”。
[10:20:42] 错误 - 打字稿 - node_modules\typescriptlib.es5.d.ts(1287,10): 错误 TS2300: 重复标识符 'Promi
瑟'。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

PeteAndersen picture PeteAndersen  ·  3评论

taikongfeizhu picture taikongfeizhu  ·  3评论

alanwei0 picture alanwei0  ·  3评论

plandem picture plandem  ·  3评论

longhuasishen picture longhuasishen  ·  3评论