Reputation: 1227
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",
Upvotes: 1
Views: 1440
Reputation: 40692
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
Upvotes: 2