Ant-design: TS2304: Cannot find name 'PropertyKey'.

Created on 18 Jul 2017  ·  3Comments  ·  Source: ant-design/ant-design

Version

2.12.1

Environment

macOS 10.12.3

Reproduction link

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

Steps to reproduce

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

yarn install

yarn build

What is expected?

It should build without problem

What is actually happening?

➜ 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.

Most helpful comment

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"
        ]

All 3 comments

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', but here has type 'WeakMap ny, any>'.
[10:20:42] Error - typescript - node_modules\@types\es6-collections\index.d.ts(87,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(102,4): error TS2403: Subsequent variable dec
larations must have the same type. Variable 'prototype' must be of type 'WeakSet', but here has type 'WeakSet'
.
[10:20:42] Error - typescript - node_modules\@types\es6-collections\index.d.ts(102,4): error TS2687: All declarations of 'pr
ototype' must have identical modifiers.
[10:20:42] Error - typescript - node_modules\@types\es6-promise\index.d.ts(10,14): error TS2300: Duplicate identifier 'Promi
se'.
[10:20:42] Error - typescript - node_modules\@types\es6-promise\index.d.ts(41,18): error TS2300: Duplicate identifier 'Promi
se'.
[10:20:42] Error - typescript - node_modules\@types\lodash\index.d.ts(19448,14): error TS2428: All declarations of 'WeakMap'
must have identical type parameters.
[10:20:42] Error - typescript - node_modules\typescriptliblib.es2015.collection.d.ts(44,10): error TS2428: All declaration
s of 'WeakMap' must have identical type parameters.
[10:20:42] Error - typescript - node_modules\typescriptliblib.es2015.iterable.d.ts(156,10): error TS2428: All declarations
of 'WeakMap' must have identical type parameters.
[10:20:42] Error - typescript - node_modules\typescriptliblib.es2015.iterable.d.ts(210,10): error TS2300: Duplicate identi
fier 'Promise'.
[10:20:42] Error - typescript - node_modules\typescriptliblib.es2015.promise.d.ts(222,12): error TS2300: Duplicate identif
ier 'Promise'.
[10:20:42] Error - typescript - node_modules\typescriptliblib.es2015.symbol.wellknown.d.ts(132,10): error TS2428: All decl
arations of 'WeakMap' must have identical type parameters.
[10:20:42] Error - typescript - node_modules\typescriptliblib.es2015.symbol.wellknown.d.ts(167,10): error TS2300: Duplicat
e identifier 'Promise'.
[10:20:42] Error - typescript - node_modules\typescriptliblib.es5.d.ts(1287,10): error TS2300: Duplicate identifier 'Promi
se'.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benthehenten picture benthehenten  ·  89Comments

zombieJ picture zombieJ  ·  75Comments

benjycui picture benjycui  ·  65Comments

duanzheng picture duanzheng  ·  74Comments

imxiongying picture imxiongying  ·  90Comments
bleepcoder.com uses publicly licensed GitHub information to provide developers around the world with solutions to their problems. We are not affiliated with GitHub, Inc. or with any developers who use GitHub for their projects. We do not host any of the videos or images on our servers. All rights belong to their respective owners.
Source for this page: Source

Popular programming languages
Popular GitHub projects
More GitHub projects

© 2024 bleepcoder.com - Contact
Made with in the Dominican Republic.
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.