Skip to content

Commit 737bcbb

Browse files
authored
fix(clerk-js,types): Add type for __internal_country (#4215)
1 parent d61bef1 commit 737bcbb

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

.changeset/lazy-rabbits-fry.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@clerk/clerk-js": patch
3+
"@clerk/types": patch
4+
---
5+
6+
Add type for \_\_internal_country

packages/clerk-js/src/ui/elements/PhoneInput/PhoneInput.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ const CountryCodeListItem = memo((props: CountryCodeListItemProps) => {
246246

247247
export const PhoneInput = forwardRef<HTMLInputElement, PhoneInputProps & { feedbackType?: FeedbackType }>(
248248
(props, ref) => {
249-
// @ts-expect-error
250249
const { __internal_country } = useClerk();
251250

252251
return (

packages/types/src/clerk.ts

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ export interface Clerk {
137137

138138
telemetry: TelemetryCollector | undefined;
139139

140+
__internal_country?: string | null;
141+
140142
/**
141143
* Signs out the current user on single-session instances, or all users on multi-session instances
142144
* @param signOutCallback - Optional A callback that runs after sign out completes.

packages/ui/src/common/phone-number-field.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { extractDigits, formatPhoneNumber, parsePhoneString } from '~/utils/phon
1717

1818
type UseFormattedPhoneNumberProps = {
1919
initPhoneWithCode: string;
20-
locationBasedCountryIso?: CountryIso;
20+
locationBasedCountryIso?: CountryIso | null;
2121
};
2222

2323
const format = (str: string, iso: CountryIso) => {
@@ -93,8 +93,7 @@ export const PhoneNumberField = React.forwardRef(function PhoneNumberField(
9393
forwardedRef: React.ForwardedRef<HTMLInputElement>,
9494
) {
9595
const clerk = useClerk();
96-
// TODO to fix IsomorphicClerk
97-
const locationBasedCountryIso = (clerk as any)?.clerkjs.__internal_country;
96+
const locationBasedCountryIso = clerk.__internal_country as UseFormattedPhoneNumberProps['locationBasedCountryIso'];
9897
const { t, translateError } = useLocalizations();
9998
const [isOpen, setOpen] = React.useState(false);
10099
const [selectedCountry, setSelectedCountry] = React.useState(countryOptions[0]);

0 commit comments

Comments
 (0)