-
-
Notifications
You must be signed in to change notification settings - Fork 432
Typescript: this.fetch returns a Response #1603
Typescript: this.fetch returns a Response #1603
Conversation
Yeah, you're right. However, |
Actually, it looks like this might need #1604 first |
When I test this change locally, it appears to work just fine. I'm not sure how to write an automated test for it... |
Ok. I think you need to specify |
Not sure if this is correct. Fetch depends on the environment it is used in, and some server environments may have a different interface. |
Maybe something like? Now |
Not sure if this would bring much benefit over the user just casting it himself. It also makes it "easier" to introduce breaking changes later on if we would want to add more generics like this to the function later on. |
I'm not sure I follow. I think Sapper uses |
Is |
I would expect it to be deployed along with the user's app since it's one of Sapper's dependencies: Line 53 in 28e6231
|
This is isomorphic code, but the result will be slightly different on server and client. On the client it will always be We should add typings that represent the guarantee of functionality that is always available, which is presumably a subset of Btw, we should add types to |
Looks like the only typing difference is the missing How about this? import type fetchType from 'node-fetch'
type PreloadFetchResponse = Response | ReturnType<typeof fetchType> |
That seems like a good idea to me! It does express what type it indeed really is. |
No description provided.