gpt4 book ai didi

typescript - 运行 typescript 文件显示错误消息为 TS2304 : Cannot find name 'PropertyKey' & Error TS2339

转载 作者:行者123 更新时间:2023-12-02 17:08:39 25 4
gpt4 key购买 nike

我正在尝试在 Jasmine Framework 中运行 spec.ts 文件,但是在使用以下命令 npm i @types/core-js 安装 @types/core-js 版本 0.9.46 之后抛出以下错误消息:

>

 ../../node_modules/@types/core-js/index.d.ts(358,34): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(359,34): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(360,61): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(361,60): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(362,65): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(362,97): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(363,60): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(364,58): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(365,59): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(366,58): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(367,61): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(367,117): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(368,42): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(370,81): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(371,78): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(372,76): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(373,73): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(469,59): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(470,59): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(472,48): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(473,69): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(477,40): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(479,48): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(695,55): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(696,45): error TS2304:
> Cannot find name 'PropertyKey'.
> ../../node_modules/@types/core-js/index.d.ts(829,20): error TS2304:
> Cannot find name 'PromiseConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1486,36): error TS2339:
> Property 'for' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1490,43): error TS2339:
> Property 'hasInstance' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1494,50): error TS2339:
> Property 'isConcatSpreadable' does not exist on type
> 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1502,38): error TS2339:
> Property 'keyFor' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1506,37): error TS2339:
> Property 'match' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1510,39): error TS2339:
> Property 'replace' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1514,38): error TS2339:
> Property 'search' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1518,39): error TS2339:
> Property 'species' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1522,37): error TS2339:
> Property 'split' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1526,43): error TS2339:
> Property 'toPrimitive' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1530,43): error TS2339:
> Property 'toStringTag' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(1534,43): error TS2339:
> Property 'unscopables' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2305,36): error TS2339:
> Property 'for' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2309,43): error TS2339:
> Property 'hasInstance' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2313,50): error TS2339:
> Property 'isConcatSpreadable' does not exist on type
> 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2321,38): error TS2339:
> Property 'keyFor' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2325,37): error TS2339:
> Property 'match' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2329,39): error TS2339:
> Property 'replace' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2333,38): error TS2339:
> Property 'search' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2337,39): error TS2339:
> Property 'species' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2341,37): error TS2339:
> Property 'split' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2345,43): error TS2339:
> Property 'toPrimitive' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2349,43): error TS2339:
> Property 'toStringTag' does not exist on type 'SymbolConstructor'.
> ../../node_modules/@types/core-js/index.d.ts(2353,43): error TS2339:
> Property 'unscopables' does not exist on type 'SymbolConstructor'.

最佳答案

Use core-js only as a polyfill .不要安装 npm i @types/core-js。而是使用 lib optiontsconfig.json 中:

"compilerOptions": {
"lib": ["dom", "es6"]
}

关于typescript - 运行 typescript 文件显示错误消息为 TS2304 : Cannot find name 'PropertyKey' & Error TS2339,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50434823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com