diff options
author | 2025-04-22 13:05:13 +0200 | |
---|---|---|
committer | 2025-04-22 12:05:13 +0100 | |
commit | a19a185efd75334f2f417b433fcfaa0017fe41ee (patch) | |
tree | 853831aa7f68a8e0ee1aab0b231ba5d22b42c61c /packages/integrations/react/src/context.ts | |
parent | 620d15d8483dfb1822cd47833bc1653e0b704ccb (diff) | |
download | astro-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; |