Skip to content

fix(blocks): type siteLoaderRefs so schema.ts compiles with noImplicitAny [7.x] - #778

Merged
guitavano merged 1 commit into
7.xfrom
fix/schema-implicit-any-7x
Nov 6, 2026
Merged

guitavano merged 1 commit into
7.xfrom
fix/schema-implicit-any-7x

Conversation

@guitavano

@guitavano guitavano commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

@decocms/blocks 7.x publishes its TypeScript source, so a consuming site's tsc and next build check src/cms/schema.ts with the site's own compiler options. skipLibCheck doesn't help, because it only covers .d.ts files.

A site that enables noImplicitAny gets one error from the package:

node_modules/@decocms/blocks/src/cms/schema.ts: error TS7006: Parameter 'r' implicitly has an 'any' type.

schema.root is Record<string, any>, so siteLoaderRefs ends up as any and the .filter((r) => ...) callback has no contextual type. The site can't work around it from its side: the error blocks next build.

Fix

Annotate siteLoaderRefs as { $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.ts goes from 1 error to 0. The other 7 errors are in sectionLoaders.test.ts and useScript.test.ts, which this PR doesn't touch.
  • vitest run packages/blocks/src/cms: 333 tests pass.

biome check on this file reports the same two items with and without this change (a format issue around line 955 and useOptionalChain at 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 run noImplicitAny in a separate script because of this error.

🤖 Generated with Claude Code


Summary by cubic

Fixes @decocms/blocks 7.x so src/cms/schema.ts compiles when consuming sites enable noImplicitAny. The package ships TypeScript source, so tsc and next build check it with each site's compiler options; siteLoaderRefs was inferred as any, 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.

View guided diff Turn on auto-fix

…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]>
@guitavano
guitavano merged commit df6a309 into 7.x Nov 6, 2026
1 check passed
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 7.84.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant