I am declaring an object apiClient like so:
const { apiClient } : any = useAuth();
Is there anyway that I can declare the type of apiClient so I can use intellisense?
I tried
const { apiClient } : { apiClient : JsonServiceClient } = useAuth();
But get error:
Property 'apiClient' is missing in type '{}' but required in type '{ apiClient: JsonServiceClient; }'.ts(2741)
useAuth() is declared in a normal js file so it doesn't have a return type.
CodePudding user response:
Try
const { apiClient } = useAuth() as { apiClient : JsonServiceClient };