Answer the question
In order to leave comments, you need to log in
Why does objectB Instanceof InterfaceA return only refers to a type, but is being used as a value here?
/**
* Reference: https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiauth2authorizeresponse
*/
interface AuthorizeResponse {
access_token: string;
id_token: string;
code: string;
scope: string;
expires_in: number;
first_issued_at: number;
expires_at: number;
error: string;
error_subtype: string;
}
gAuthenticate(): void {
gapi.auth2.authorize(this.gapiConfig, response => {
if (response.error || response instanceof AuthorizeResponse) {
TS2693: 'AuthorizeResponse' only refers to a type, but is being used as a value here.
Answer the question
In order to leave comments, you need to log in
Because instanceof works at runtime when there is no typescript anymore, and by and large only with classes.
So the SO answer is the only way. Official documentation https://www.typescriptlang.org/docs/handbook/advan...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question