diff --git a/packages/next/src/lib/metadata/resolvers/resolve-basics.ts b/packages/next/src/lib/metadata/resolvers/resolve-basics.ts index b10954e02756..1e69c4d61353 100644 --- a/packages/next/src/lib/metadata/resolvers/resolve-basics.ts +++ b/packages/next/src/lib/metadata/resolvers/resolve-basics.ts @@ -66,7 +66,10 @@ export const resolveViewport: FieldResolver<'viewport'> = (viewport) => { function resolveUrlValuesOfObject( obj: - | Record + | Record< + string, + string | URL | AlternateLinkDescriptor[] | null | undefined + > | null | undefined, metadataBase: ResolvedMetadata['metadataBase'], diff --git a/packages/next/src/lib/metadata/types/alternative-urls-types.ts b/packages/next/src/lib/metadata/types/alternative-urls-types.ts index fd54da9c87a0..ac38a148076b 100644 --- a/packages/next/src/lib/metadata/types/alternative-urls-types.ts +++ b/packages/next/src/lib/metadata/types/alternative-urls-types.ts @@ -412,7 +412,15 @@ type LangCode = | 'zh-MO' | 'zh-SG' | 'zh-TW' + | 'zh-Hans' + | 'zh-Hant' | 'zu-ZA' + // We can't have all valid combinations of language-region-script listed here + // as the list is too long and breaks the TypeScript compiler. So instead we + // only add the most common ones with a general string pattern for the rest. + // This way autocompletion still works and it is still possible to add custom + // lang codes. + | `${Lowercase}-${string}` type UnmatchedLang = 'x-default'