Skip to content

Commit f273427

Browse files
committed
chore: edit after review
1 parent 5c4c1af commit f273427

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/internal/locale-proxy.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ export type LocaleProxy = Readonly<
1212
LocaleDefinition[key]
1313
>;
1414
} & {
15+
/**
16+
* The raw locale definition used to create this proxy.
17+
* This can be useful to check if a category/entry exists without triggering the proxy's error.
18+
*/
1519
raw: LocaleDefinition;
20+
/**
21+
* Marker to identify a `LocaleProxy`.
22+
*/
1623
[LOCALE_PROXY_TAG]: true;
1724
}
1825
>;
@@ -36,7 +43,11 @@ const throwReadOnlyError: () => never = () => {
3643
*/
3744
function isLocaleProxy(value: unknown): value is LocaleProxy {
3845
// eslint-disable-next-line @typescript-eslint/no-explicit-any
39-
return (value as any)?.[LOCALE_PROXY_TAG] === true;
46+
return (
47+
value != null &&
48+
typeof value === 'object' &&
49+
(value as any)?.[LOCALE_PROXY_TAG] === true
50+
);
4051
}
4152

4253
/**

0 commit comments

Comments
 (0)