简体   繁体   中英

TypeScript error: TS2304:Cannot find name 'Date'

I am trying to create a date object of javascript to store current date and time

let now:Date = new Date(); 

But the below line show error in my intellij as the below error:

TS2304:Cannot find name 'Date'.

I am guessing as Date is javascript object and new Date() is not available in typescript or in my project, its failing.

I am writing angularjs 1.5.9 in typescript, I dont thing is anything related to angularjs.

How to fix this?

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

Step 2. Then choose Use Workspace version.

You will be good to go.

var today = new Date()尝试这个var today = new Date()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM