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 添加到项目时遇到了问题。
因为PropertyKey
在es2015
库中,所以你应该在编译中包含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”类型
最有用的评论
因为
PropertyKey
在es2015
库中,所以你应该在编译中包含es2015
,在tsconfig.json
添加lib
选项。