Repository navigation
fix(blocks): type siteLoaderRefs so schema.ts compiles with noImplicitAny [7.x] - #778
Merged
Merged
Conversation
…tAny The package publishes its TypeScript source, so sites check this file with their own compiler options. `root` is `Record<string, any>`, which made the filtered list `any` and left the `r` callback parameter implicitly typed: TS7006 fails tsc and next build on any site that enables noImplicitAny. Type-only, no runtime change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🎉 This PR is included in version 7.84.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
@decocms/blocks7.x publishes its TypeScript source, so a consuming site'stscandnext buildchecksrc/cms/schema.tswith the site's own compiler options.skipLibCheckdoesn't help, because it only covers.d.tsfiles.A site that enables
noImplicitAnygets one error from the package:schema.rootisRecord<string, any>, sositeLoaderRefsends up asanyand the.filter((r) => ...)callback has no contextual type. The site can't work around it from its side: the error blocksnext build.Fix
Annotate
siteLoaderRefsas{ $ref: string }[], which is what its type guard already says. This is type-only, so the emitted JS doesn't change.Verification
In
packages/blocks:tsc --noEmit: 0 errors, as before.tsc --noEmit --noImplicitAny:src/cms/schema.tsgoes from 1 error to 0. The other 7 errors are insectionLoaders.test.tsanduseScript.test.ts, which this PR doesn't touch.vitest run packages/blocks/src/cms: 333 tests pass.biome checkon this file reports the same two items with and without this change (a format issue around line 955 anduseOptionalChainat line 1139). I left them alone to keep the diff to one line.Found on the Pague Menos storefront (
pmenos/fast-store-pmenos, PR #588), which has to runnoImplicitAnyin a separate script because of this error.🤖 Generated with Claude Code
Summary by cubic
Fixes
@decocms/blocks7.x sosrc/cms/schema.tscompiles when consuming sites enablenoImplicitAny. The package ships TypeScript source, sotscandnext buildcheck it with each site's compiler options;siteLoaderRefswas inferred asany, which left the.filter()callback parameter implicitly typed and failed the build. Annotating it as{ $ref: string }[]is type-only, so the emitted JS is unchanged.Written for commit 32d8087. Summary will update on new commits.