Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS2304: Cannot find name 'PropertyKey'. #6874

Closed
tylerlong opened this issue Jul 17, 2017 · 3 comments
Closed

TS2304: Cannot find name 'PropertyKey'. #6874

tylerlong opened this issue Jul 17, 2017 · 3 comments

Comments

@tylerlong
Copy link

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 typescript@2.4.1 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.

@infeng
Copy link
Contributor

infeng commented Jul 18, 2017

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

@tylerlong
Copy link
Author

It works! Thanks

Adding the following is sufficient:

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

@bva999
Copy link

bva999 commented Sep 5, 2017

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<object, any>', but here has type 'WeakMap<a
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\typescript\lib\lib.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\typescript\lib\lib.es2015.iterable.d.ts(156,10): error TS2428: All declarations
of 'WeakMap' must have identical type parameters.
[10:20:42] Error - typescript - node_modules\typescript\lib\lib.es2015.iterable.d.ts(210,10): error TS2300: Duplicate identi
fier 'Promise'.
[10:20:42] Error - typescript - node_modules\typescript\lib\lib.es2015.promise.d.ts(222,12): error TS2300: Duplicate identif
ier 'Promise'.
[10:20:42] Error - typescript - node_modules\typescript\lib\lib.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\typescript\lib\lib.es2015.symbol.wellknown.d.ts(167,10): error TS2300: Duplicat
e identifier 'Promise'.
[10:20:42] Error - typescript - node_modules\typescript\lib\lib.es5.d.ts(1287,10): error TS2300: Duplicate identifier 'Promi
se'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants