For example, in:
const getLoc = new Promise(navigator.geolocation.getCurrentPosition);
Typescript seems to infer the type Promise<Position>
correctly without error, but the browser gives:
Unhandled Rejection (TypeError): 'getCurrentPosition' called on an object that does not implement interface Geolocation.
if we eta expand to
const getLoc = new Promise((r,e) => navigator.geolocation.getCurrentPosition(r,e));
Then it runs without issue, but this seems unnecessarily verbose, and screws with type inference (gives Promise<unknown>
instead without manual annotation). So I want to understand what's actually going on.
I suspect it has something to do with the binding of this
but I have no idea what to search for to figure it out.
I think the same thing is going on for this question, but there's no explanation to the solution.