Visual Studio 代码显示错误“找不到名称日期" [英] Visual studio code showing error "Can't find name Date"

查看:50
本文介绍了Visual Studio 代码显示错误“找不到名称日期"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio 代码(版本 1.19.2) 作为我的 IDE.

I am working on a basic Angular project with Visual studio code(Version 1.19.2) as my IDE.

以下代码运行良好,但 VSC 似乎对此并不满意.

The following piece of code is working fine but VSC doesn't seem to be happy about it.

当我使用 new Date()JSON.stringify

但最终结果是正确的,控制台打印正常.

But the end results are correct and the console prints fine.

如何从 Visual Studio 代码中删除此错误?

How to remove this error from Visual studio code?

更新 1

这是我的依赖项

  "devDependencies": {
    "@angular-devkit/build-angular": "~0.10.0",
    "@angular/cli": "~7.0.3",
    "@angular/compiler-cli": "~7.0.0",
    "@angular/language-service": "~7.0.0",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.1.1"
  }

推荐答案

我的 Visual Studio 代码 使用的是 Typescript v2.6.2.

正如 @Jai 所提到的,我更新了 VSC 的打字稿版本以匹配我的 Angular 项目的打字稿版本,在我的例子中是 Typescript v3.1.1.

As mentioned by @Jai I updated the VSC's typescript version to match the Typescript version of my Angular project, which in my case was Typescript v3.1.1.

更新打字稿版本

第 1 步.只需单击 Visual Studio 代码页脚中显示的版本.

Step 1. Simply click on the version displayed in the footer of your visual studio code.

第 2 步.然后选择使用工作区版本.

你会很高兴的.

PS:特别感谢 @Jai.

这篇关于Visual Studio 代码显示错误“找不到名称日期"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆