I don't know what's going on here... but apparently TS is not recognizing Date as Date, instead it thinks it is a string.
Here's the code I use to save the Date
:
var validUntil = new Date();
validUntil.setSeconds(validUntil.getSeconds() + tokenResponse.expires_in);
tokenResponse.valid_until = validUntil;
And this is my TokenResponse
class:
export class TokenResponse {
access_token: string;
token_type: string;
expires_in: number;
valid_until: Date;
error: string;
error_description: string;
}
And here is where the exception is thrown:
userToken && userToken.valid_until.getTime() >= new Date().getTime()
Here's the exception:
Any ideas on what's wrong?
Thanks!
EDIT
By the way, I don't think it's related to Date variable works, but functions on it do not since I'm creating a new Date