Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Aug 28, 2024
1 parent 241bfc7 commit 3940674
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function getAlternateLinksHeaderValue<
}

const links = getLocalePrefixes(
routing.locales,
routing.locales as AppLocales,
routing.localePrefix
).flatMap(([locale, prefix]) => {
function prefixPathname(pathname: string) {
Expand Down Expand Up @@ -114,7 +114,6 @@ export default function getAlternateLinksHeaderValue<
}

if (
// @ts-expect-error -- This is fine
locale !== routing.defaultLocale ||
routing.localePrefix.mode === 'always'
) {
Expand Down
5 changes: 2 additions & 3 deletions packages/next-intl/src/middleware/middleware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,11 @@ export default function createMiddleware<
resolvedRouting.localePrefix.mode === 'as-needed');

let response;
let internalTemplateName: keyof NonNullable<AppPathnames>;
let internalTemplateName: keyof AppPathnames | undefined;

let unprefixedInternalPathname = unprefixedExternalPathname;
if ('pathnames' in resolvedRouting && resolvedRouting.pathnames) {
if ('pathnames' in resolvedRouting) {
let resolvedTemplateLocale: AppLocales[number] | undefined;
// @ts-expect-error -- We've validated that `pathnames` is defined
[resolvedTemplateLocale, internalTemplateName] = getInternalTemplate(
resolvedRouting.pathnames,
unprefixedExternalPathname,
Expand Down
2 changes: 1 addition & 1 deletion packages/next-intl/src/routing/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type RoutingConfig<
* Used when no locale matches.
* @see https://next-intl-docs.vercel.app/docs/routing
*/
defaultLocale: NoInfer<AppLocales[number]>;
defaultLocale: AppLocales[number];

/**
* Configures whether and which prefix is shown for a given locale.
Expand Down
6 changes: 2 additions & 4 deletions packages/next-intl/src/routing/defineRouting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {Locales, Pathnames} from './types';
export default function defineRouting<
const AppLocales extends Locales,
const AppPathnames extends Pathnames<AppLocales> = never
>(
config: RoutingConfig<AppLocales, AppPathnames>
): RoutingConfig<AppLocales, AppPathnames> {
return config as RoutingConfig<AppLocales, AppPathnames>;
>(config: RoutingConfig<AppLocales, AppPathnames>) {
return config;
}

0 comments on commit 3940674

Please sign in to comment.