typescript 错误 - node_modules\@types\jasmine\index.d.ts(138,230) TS1005: ')' 预期

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53294979/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 05:42:47  来源:igfitidea点击:

Error - node_modules\@types\jasmine\index.d.ts(138,230) TS1005: ')' expected

typescriptjasminekarma-jasmine

提问by ananya

Below is the versions i am using "@types/jasmine": "^2.8.9" "typescript": "~2.6.2"

以下是我使用的版本 "@types/jasmine": "^2.8.9" "typescript": "~2.6.2"

 "devDependencies": {
        "@ionic/app-scripts": "3.2.0",
        "@types/jasmine": "^2.8.9",
        "@types/node": "^10.12.5",
        "angular2-template-loader": "^0.6.2",
        "html-loader": "^0.5.5",
        "istanbul-instrumenter-loader": "^3.0.1",
        "jasmine": "^3.3.0",
        "jasmine-spec-reporter": "^4.2.1",
        "karma": "^3.1.1",
        "karma-chrome-launcher": "^2.2.0",
        "karma-coverage-istanbul-reporter": "^2.0.4",
        "karma-jasmine": "^1.1.2",
        "karma-jasmine-html-reporter": "^1.4.0",
        "karma-sourcemap-loader": "^0.3.7",
        "karma-webpack": "^3.0.5",
        "null-loader": "^0.1.1",
        "protractor": "^5.4.1",
        "ts-loader": "^3.5.0",
        "ts-node": "^7.0.1",
        "typescript": "~2.6.2"
      },

But still i am getting the below error

但我仍然收到以下错误

Error: node_modules/@types/jasmine/index.d.ts(138,47): error TS1005: ';' expected.
node_modules/@types/jasmine/index.d.ts(138,90): error TS1005: '(' expected.
node_modules/@types/jasmine/index.d.ts(138,104): error TS1005: ']' expected.
node_modules/@types/jasmine/index.d.ts(138,112): error TS1005: ',' expected.
node_modules/@types/jasmine/index.d.ts(138,113): error TS1136: Property assignment expected.
node_modules/@types/jasmine/index.d.ts(138,121): error TS1005: ')' expected.
node_modules/@types/jasmine/index.d.ts(138,147): error TS1005: '(' expected.
node_modules/@types/jasmine/index.d.ts(138,162): error TS1005: ']' expected.
node_modules/@types/jasmine/index.d.ts(138,163): error TS1005: ',' expected.
node_modules/@types/jasmine/index.d.ts(138,164): error TS1136: Property assignment expected.
node_modules/@types/jasmine/index.d.ts(138,165): error TS1136: Property assignment expected.
node_modules/@types/jasmine/index.d.ts(138,179): error TS1005: ',' expected.
node_modules/@types/jasmine/index.d.ts(138,183): error TS1005: ':' expected.
node_modules/@types/jasmine/index.d.ts(138,208): error TS1005: '{' expected.
node_modules/@types/jasmine/index.d.ts(138,217): error TS1005: ':' expected.
node_modules/@types/jasmine/index.d.ts(138,222): error TS1005: ',' expected.
node_modules/@types/jasmine/index.d.ts(138,227): error TS1005: ':' expected.
node_modules/@types/jasmine/index.d.ts(138,228): error TS1109: Expression expected.
node_modules/@types/jasmine/index.d.ts(138,230): error TS1005: ')' expected.

I am not getting how to resolve this. Can anyone please help me.

我不知道如何解决这个问题。谁能帮帮我吗。

回答by Mehak Fatima

If you are still having the issue, in package.json add

如果您仍然遇到问题,请在 package.json 添加

"typescript": "^2.9.2"

“打字稿”:“^2.9.2”

Run npm install.

运行 npm 安装。

It should work.

它应该工作。

回答by monikaja

I have fixed it changing my package versions:

我已经修复它改变我的包版本:

"@types/jasmine": "2.8.6",
"@types/jasminewd2": "2.0.3",

Founded in this post: Angular 4+ : Sudden @types/jasmine error at runtime (npm start)

在这篇文章中建立: Angular 4+:运行时突然出现@types/jasmine 错误(npm start)

回答by Yogesh Kumar

You have just change [email protected] and @types/[email protected]

您刚刚更改了 [email protected] 和 @types/[email protected]

Like

喜欢

  1. npm install [email protected] --save-dev
  2. npm install @types/[email protected] --save-dev
  1. npm install [email protected] --save-dev
  2. npm install @types/[email protected] --save-dev

It's working 100%.

它工作 100%。

Thanks,

谢谢,

回答by Jay

If you have reached this page when you are not using Jasmine anywhere in your application, then I would suggest checking your import statements on the top of your ts file. It should have this added on the top:

如果您在应用程序的任何地方都没有使用 Jasmine 时访问了此页面,那么我建议您检查 ts 文件顶部的导入语句。它应该在顶部添加这个:

import { ConsoleReporter } from 'jasmine';

I saw this accidentally added on the top when I was using console object to log into the browser and the autocomplete feature of VS Code completed it with ConsoleReporter and this import statement was added. Removing this statement fixed my issue.

当我使用控制台对象登录浏览器时,我意外地在顶部看到了这个,并且 VS Code 的自动完成功能使用 ConsoleReporter 完成了它,并添加了这个导入语句。删除此语句解决了我的问题。

回答by Remy Ticona

Try this: install ncu

试试这个:安装 ncu

npm install -g npm-check-updates

Update tsc easily:

轻松更新 tsc:

ncu -u
npm install

That's it all, enjoy!.

就这样,尽情享受吧!

回答by Vikas

  1. Step 1. You need to remove "~" before 2.8.6 or 2.8.9 in package.json
  2. Step 2. Remove the package-lock.json file and node_modules folder
  3. Step 3. Run "npm cache clean --force" and "npm install"
  1. Step 1. 需要去掉package.json中2.8.6或2.8.9之前的“~”
  2. 步骤 2. 删除 package-lock.json 文件和 node_modules 文件夹
  3. 步骤 3. 运行“npm cache clean --force”和“npm install”