2.12.1
macOS 10.12.3
https://github.com/tylerlong/react-antd-ts-test
git clone https://github.com/tylerlong/react-antd-ts-test
yarn install
yarn build
It should build without problem
➜ ts-test git:(master) ✗ yarn build
yarn build v0.22.0
$ webpack
[at-loader] Using [email protected] from typescript and "tsconfig.json" from /Users/tylerlong/src/react/ts-test/tsconfig.json.
[at-loader] Checking started in a separate process...
[at-loader] Checking finished with 2 errors
Hash: c0b8bc6cbb418f703794
Version: webpack 3.3.0
Time: 11342ms
Asset Size Chunks Chunk Names
bundle.js 3.67 MB 0 [emitted] [big] main
bundle.js.map 3.83 MB 0 [emitted] main
[28] (webpack)/buildin/global.js 509 bytes {0} [built]
[120] (webpack)/buildin/module.js 517 bytes {0} [built]
[396] ./src/index.tsx 334 bytes {0} [built]
[503] ./node_modules/moment/locale ^.\/.*$ 2.79 kB {0} [optional] [built]
[790] (webpack)/buildin/amd-options.js 82 bytes {0} [built]
909 hidden modules
ERROR in [at-loader] ./node_modules/antd/lib/table/Table.d.ts:109:27
TS2304: Cannot find name 'PropertyKey'.
ERROR in [at-loader] ./node_modules/antd/lib/table/Table.d.ts:112:33
TS2304: Cannot find name 'PropertyKey'.
error Command failed with exit code 2.
The demo project was created according to https://www.typescriptlang.org/docs/handbook/react-&-webpack.html
And I am having issue when trying to add antd to the project.
Because PropertyKey
is in es2015
library, so you should included es2015
in the compilation, add lib
option in tsconfig.json
.
"lib": [
"es5",
"dom",
"dom.iterable",
"es2015"
]
It works! Thanks
Adding the following is sufficient:
"lib": [
"dom",
"es2015"
],
I have the same issue.
Version 2.13.0
After adding:
"lib": [
"dom",
"es2015"
],
I have got a lot of errors:
Error - typescript - node_modules\@types\es6-collections\index.d.ts(22,4): error TS2687: All declarations of 'val
ue' must have identical modifiers.
[10:20:42] Error - typescript - node_modules\@types\es6-collections\index.d.ts(45,4): error TS2687: All declarations of 'siz
e' must have identical modifiers.
[10:20:42] Error - typescript - node_modules\@types\es6-collections\index.d.ts(51,4): error TS2687: All declarations of 'pro
totype' must have identical modifiers.
[10:20:42] Error - typescript - node_modules\@types\es6-collections\index.d.ts(65,4): error TS2687: All declarations of 'siz
e' must have identical modifiers.
[10:20:42] Error - typescript - node_modules\@types\es6-collections\index.d.ts(71,4): error TS2687: All declarations of 'pro
totype' must have identical modifiers.
[10:20:42] Error - typescript - node_modules\@types\es6-collections\index.d.ts(76,10): error TS2428: All declarations of 'We
akMap' must have identical type parameters.
[10:20:42] Error - typescript - node_modules\@types\es6-collections\index.d.ts(85,26): error TS2344: Type 'K' does not satis
fy the constraint 'object'.
[10:20:42] Error - typescript - node_modules\@types\es6-collections\index.d.ts(86,55): error TS2344: Type 'K' does not satis
fy the constraint 'object'.
[10:20:42] Error - typescript - node_modules\@types\es6-collections\index.d.ts(87,4): error TS2403: Subsequent variable decl
arations must have the same type. Variable 'prototype' must be of type 'WeakMap
Most helpful comment
Because
PropertyKey
is ines2015
library, so you should includedes2015
in the compilation, addlib
option intsconfig.json
.