Repository navigation
fix(optimize-locales-plugin): type Turbopack loader locales as a mutable array - #10889
Open
costajohnt wants to merge 1 commit into
Open
costajohnt wants to merge 1 commit into
costajohnt wants to merge 1 commit into
Conversation
…ble array Next's TurbopackLoaderOptions only accepts mutable JSONValue arrays, so the readonly locales type made optimizeLocales.turbopack() rules fail to type-check in a NextConfig.
devongovett
approved these changes
Oct 29, 2026
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.
Closes #10880
optimizeLocales.turbopack()declares each loader's options as{locales: readonly string[]}. Next'sTurbopackLoaderOptionsisRecord<string, JSONValue>, andJSONValue[]is a mutable array, so spreading the returnedrulesinto a typedNextConfigfails with TS2322 even though the rule works at runtime. This changes the declared loader option tostring[], which is the change suggested in the issue. TheOptionsinput type staysreadonly string[], so callers can still passas constarrays. Only the shape handed to Next changes.I checked it against
next@16.4.2and TypeScript 6.0.3 (strict) with anext.config.tscovering a single config, a conditioned list, a readonlyas constlocales array, and apath/contentRegExp condition. With the current declaration all four report TS2322 (The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type 'JSONValue[]'). With this changetsc --noEmitpasses.✅ Pull Request Checklist:
Type-only change to a
.d.ts, so no unit test, docs or a11y change applies. The plugin directory is excluded fromyarn check-types, so the verification is the standalone check below. Drafted with Claude Code; I reviewed the change and the verification myself.📝 Test Instructions:
next@16.4.2andtypescript@6, and copy this package'sLocalesPlugin.d.tsandpackage.jsonintonode_modules/@react-aria/optimize-locales-plugin/.next.config.tsfrom optimize-locales-plugin: turbopack() rules are refused by Next 16.4's NextConfig type (readonly locales) #10880:npx tsc --noEmit --strict. It reports TS2322 onmainand passes with this branch.🧢 Your Project:
Personal