I am trying to type the subscription response data to the route parameters (this is for Strava oauth authentication)
If in the following code I put a console.log, the answer is correct.
this.route.queryParams
.subscribe(params => {
this.interaction.setToken(params.code)
this.interaction.setScope(params.scope)
stop()
}
);
But my intention is to have typed data throughout the application, that's why I would like to have something like this
this.route.queryParams
.subscribe((params: Authorization ) => {
this.interaction.setToken(params.code)
this.interaction.setScope(params.scope)
stop()
}
);
But having the Authorization interface there throws me an error
error TS2769: No overload matches this call.
I've been thinking about it for a while and I don't understand what's wrong with me, whether in the interface or where... but I haven't come to a conclusion.
By the way, the interface is as follows.
export interface Authorization {
state: string;
code: string;
scope: string;
}
My ultimate solution was the following.
I send the parameters
Params
to a proper functiongetQueryParams
In which I instantiate a new class and return the type I need to handle them for the application