Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Date not working in Typescript but working in browser console

I get this error Supplied parameters do not match any signature of call target. when I try to do this in my TypeScript file in Angular2.

console.log(Date(this.field.sowing_date));

If I execute the same thing in the Chrome Debugger I don't get any problem.

Do you know what is?

I am using:

"@angular/core": "^2.4.0" "@angular/cli": "^1.0.0-rc.4", "@angular/compiler-cli": "^2.4.0",

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You cannot pass a parameter to Date when you don't use it as a constructor (without new):

In JavaScript:

Date(); // returns current date as string
Date("1/1/2017"); // ignores the parameter and returns the current date as string

TypeScript rightfully complains because Date(param) is not a valid way to call Date.

You can use Date in TypeScript like:

let currentDateAsString : string = Date(); // if you want the current date string
let parsedDate: Date = new Date(this.field.sowing_date); // if you want to parse it.

MDN documentation on Date which explains the ways Date can be used: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!