Astro shouldn't allow importing Image or Picture from astro/components/
#13142
Labels
- P2: has workaround
Bug, but has workaround (priority)
feat: assets
Related to the Assets feature (scope)
Originally discussed in withastro/roadmap#1114
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When you start typing
Image
in the markup of an Astro component, VSCode offers to importImage
fromastro/components/Image.astro
(instead of fromastro:assets
, the right way):In Astro v4, this works ok, but in Astro v5, this will result in an error when the user runs
astro build
. Interestingly, it seems that the project must include a content collection and a dynamic route for the error to occur.This error message is unintuitive and may result in developer frustration when upgrading from v4 to v5.
Doing a code search on the direct import statement shows hundreds of repos that make this mistake.
The same error occurs for
Picture
.Additional info
Picture
insteadWhat's the expected result?
Goals
Proposed solutions
astro/components/Image.astro
so that it results in errors at type-check time, orLink to Minimal Reproducible Example
https://stackblitz.com/edit/github-cfi9o9ng?file=src%2Fpages%2Findex.astro
Run
npm run build
to see the error.Participation
Possibly, with some guidance! I'm new to the project.
The text was updated successfully, but these errors were encountered: