chore(web): Fix .d.ts overwrite build issue #10431
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A clean build would work, but trying to build again after changing something in
@redwoodjs/web
you'd get errors like theseAfter a long session with
git bisect
I narrowed it down to the commit that introduced this regression. It was #10412Specifically it's this line https://github.com/redwoodjs/redwood/pull/10412/files#diff-3a6b1602e214ff07d5aea85aead0ff0e5c99e225f658b476050cc3f730b8a8e7R5
import type { TagDescriptor } from '@redwoodjs/web'
. That pulls in all the type def files for@redwoodjs/web
and makes them input files.I tried with a relative import instead (
./src/components/htmlTags
), but got the same error.Tried a script instead of a module. Same error.
Tried putting it inside
./src/
. Same error.And when it finally did pick up on the types correctly, it revealed another type issue we had with the return value from
extractFromAssetMap
where TS couldn't figure out if it was returning the css (string[]
) or the meta tags (TagDescriptor[]
), so it gave us both (string[] | TagDescriptor[]
) which you're not really allowed to pass toisTitleTag
for example. So I had to fix that issue too.__REDWOOD__ASSET_MAP
is only used in a way where types matter in this one file, so I decided to make thewindow
type augmentation local to the module instead of global. The other place we use__REDWOOD__ASSET_MAP
is in a string that we inject in user's apps during streaming. There's no type checking/safety going on there, so a global type definition is not needed.