summaryrefslogtreecommitdiff
path: root/packages/integrations/react/src/context.ts
diff options
context:
space:
mode:
authorGravatar Florian Lefebvre <contact@florian-lefebvre.dev> 2025-04-22 13:05:13 +0200
committerGravatar GitHub <noreply@github.com> 2025-04-22 12:05:13 +0100
commita19a185efd75334f2f417b433fcfaa0017fe41ee (patch)
tree853831aa7f68a8e0ee1aab0b231ba5d22b42c61c /packages/integrations/react/src/context.ts
parent620d15d8483dfb1822cd47833bc1653e0b704ccb (diff)
downloadastro-a19a185efd75334f2f417b433fcfaa0017fe41ee.tar.gz
astro-a19a185efd75334f2f417b433fcfaa0017fe41ee.tar.zst
astro-a19a185efd75334f2f417b433fcfaa0017fe41ee.zip
feat: convert integrations to TS (#13663)
Diffstat (limited to '')
-rw-r--r--packages/integrations/react/src/context.ts (renamed from packages/integrations/react/context.js)10
1 files changed, 6 insertions, 4 deletions
diff --git a/packages/integrations/react/context.js b/packages/integrations/react/src/context.ts
index 2e3e37fd5..953c35c6a 100644
--- a/packages/integrations/react/context.js
+++ b/packages/integrations/react/src/context.ts
@@ -1,8 +1,10 @@
-const contexts = new WeakMap();
+import type { SSRResult } from 'astro';
+
+const contexts = new WeakMap<SSRResult, { currentIndex: number; readonly id: string }>();
const ID_PREFIX = 'r';
-function getContext(rendererContextResult) {
+function getContext(rendererContextResult: SSRResult) {
if (contexts.has(rendererContextResult)) {
return contexts.get(rendererContextResult);
}
@@ -16,8 +18,8 @@ function getContext(rendererContextResult) {
return ctx;
}
-export function incrementId(rendererContextResult) {
- const ctx = getContext(rendererContextResult);
+export function incrementId(rendererContextResult: SSRResult) {
+ const ctx = getContext(rendererContextResult)!;
const id = ctx.id;
ctx.currentIndex++;
return id;