I'm trying to write an interface but it keeps popin' an error:
"Property 'success' of type 'boolean' is not assignable to string index type 'PageableLaravel'
export interface PageableLaravel {
path: string;
current_page: number;
from: number;
}
export interface Pageable {
success: boolean; // <-"Property 'success' of type 'boolean' is not assignable to string index type 'PageableLaravel'
message: string; // "Property 'message' of type 'string' is not assignable to string index type 'PageableLaravel'
[key: string]: PageableLaravel
}
The [key: string]
will always change, for example:
Below is an example of a JSON returned from an API
{
success: true,
message: 'success',
pages: {//<-key name always will change
path: "XX"
//etc
}
}
{
success: true,
message: 'success',
products: {//<-key name always will change
path: "XX"
//etc
}
}
{
success: true,
message: 'success',
brands: {//<-key name always will change
path: "XX"
//etc
}
}
Is there a way to declare a key that may/may not always change?