Skip to content

Commit 95da012

Browse files
authored
🤖 Merge PR DefinitelyTyped#73695 Update clerk.io TypeScript definitions to v2 with comprehensive API coverage by @cvd2412
1 parent b82093c commit 95da012

File tree

8 files changed

+570
-246
lines changed

8 files changed

+570
-246
lines changed
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1-
// @ts-expect-error
2-
window.Clerk("click", 1);
3-
4-
// @ts-expect-error
5-
window.Clerk("call", "test");
1+
if (window.Clerk) {
2+
// @ts-expect-error
3+
window.Clerk("click", 1);
64

7-
(async () => {
8-
if (!window.Clerk) {
9-
return;
10-
}
5+
// @ts-expect-error
6+
window.Clerk("call", "invalid-endpoint");
117

12-
// $ExpectType ClerkResponseSearchPredictive
13-
const response = await window.Clerk("call", "search/predictive", {
14-
query: "predictive",
8+
// Test basic API calls
9+
window.Clerk("call", "search/predictive", {
10+
key: "test-key",
11+
query: "test",
1512
limit: 5,
13+
}, (response) => {
14+
response.result; // $ExpectType (string | number)[]
15+
response.query; // $ExpectType string
16+
// @ts-expect-error
17+
response.results;
1618
});
1719

18-
// @ts-expect-error
19-
response.results;
20+
// Test config
21+
window.Clerk("config", {
22+
key: "test-key",
23+
visitor: "auto",
24+
});
2025

21-
// $ExpectType number[]
22-
response.result;
26+
// Test cart operations
27+
window.Clerk("cart", "add", "product-123");
2328

24-
const searchResponse = await window.Clerk("call", "search/search", {
25-
query: "test",
26-
limit: 10,
29+
// Test event handling
30+
window.Clerk("on", "rendered", (content) => {
31+
content.element; // $ExpectType HTMLElement
32+
content.more(5);
2733
});
28-
29-
// $ExpectType string
30-
searchResponse.query;
31-
});
34+
}

0 commit comments

Comments
 (0)