Skip to content

Commit 7975883

Browse files
committed
mandatory candidate (even if undefined)
1 parent aafa8b7 commit 7975883

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Diff for: packages/use-intl/src/core/hasLocale.test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ it('can be called with a non-matching narrow candidate', () => {
2828
it('can be called with any candidate', () => {
2929
const locales = ['en-US', 'en-GB'] as const;
3030
expect(hasLocale(locales, 'unknown')).toBe(false);
31+
expect(hasLocale(locales, undefined)).toBe(false);
3132

3233
// Relevant since `ParamValue` in Next.js includes `string[]`
3334
expect(hasLocale(locales, ['de'])).toBe(false);

Diff for: packages/use-intl/src/core/hasLocale.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {Locale} from './AppConfig.tsx';
77
*/
88
export default function hasLocale<LocaleType extends Locale>(
99
locales: ReadonlyArray<LocaleType>,
10-
candidate?: unknown
10+
candidate: unknown
1111
): candidate is LocaleType {
1212
return locales.includes(candidate as LocaleType);
1313
}

0 commit comments

Comments
 (0)