-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type error when passing Astro object to APIRoute #8514
Comments
Is there a property that's missing or not expected? That TS error isn't the greatest to read. |
The type is hard to read because of the many generics that are unfortunately needed for editor tooling, but I think the error is simply that APIContext has a ResponseWithEncoding property that the Astro global doesn't have |
Ah ok, we can probably add that. |
Is it a correct usage of the route endpoints? |
Yeah, after discussing this with some others, I'm not sure that we want to make it a breaking change if the API endpoint context types are unaligned with the Astro global. We do want to make them aligned when possible, but it shouldn't be a breaking change when they are not. |
I have the same issue. How to fix it? |
@matthewp Is there a workaround to this issue? Do we need to downgrade to use API endpoints? This appears to be a breaking change. |
Meh, the only answer is types-torturing-casting? This is one of the examples showed in the documentation and it does just not work out of the box... |
Should be fixed in 4.0. No more torturing-casting with the current beta! |
It's working in 4.0 but note that we do not have tests that enforce that it doesn't break again. Since this is not an official feature yet, it's not guaranteed to work. But if someone wants to submit tests to check that it does, would likely accept! |
Still having this type problem. The error message:
The code:
package.json
|
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Calling endpoint in the server and passing Astro object to APIRoute produces error
whole example can be found in Astro [call-endpoints recipe](https://docs.astro.build/en/recipes/call-endpoints/
This is regression with Astro 3.0, 2.10 did not have this issue.
What's the expected result?
No type error.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-huqjmk?file=src%2Fpages%2Findex.astro
Participation
The text was updated successfully, but these errors were encountered: