Skip to content

fix(analytics): change method return types from void to Promise<void>#2409

Open
muhammedaksam wants to merge 1 commit into
wxt-dev:mainfrom
muhammedaksam:fix/analytics-await-return-types
Open

fix(analytics): change method return types from void to Promise<void>#2409
muhammedaksam wants to merge 1 commit into
wxt-dev:mainfrom
muhammedaksam:fix/analytics-await-return-types

Conversation

@muhammedaksam

Copy link
Copy Markdown
Contributor

Overview

The Analytics interface declared track(), page(), identify(), and setEnabled() as returning void. The background implementation is async so it actually returns Promise<void>, but the frontend implementation returns void. TypeScript allows Promise<void> to be assigned to void (no error on the background side), but users calling await analytics.track() see TS80007 because the declared return type is void.
Changed the interface return types to Promise<void> and updated the MethodForwarder type and frontend implementation accordingly.

Manual Testing

  1. Use await analytics.track(...), await analytics.page(...), await analytics.identify(...), or await analytics.setEnabled(...) in a WXT project using this analytics module — TS80007 should no longer appear
  2. Call the same methods without await — they should still work in both background and frontend contexts
  3. Verify the build passes: bun run --filter @wxt-dev/analytics build

Related Issue

This PR closes #2408

The Analytics interface declared track(), page(), identify(), and setEnabled()
as returning void. The background implementation returns Promise<void> (async
functions), which is assignable to void. But users calling await analytics.track()
get TS80007 since the declared type is void.

Changed the interface return types to Promise<void> and updated the
MethodForwarder type and implementation accordingly.
@muhammedaksam muhammedaksam requested a review from aklinker1 as a code owner June 9, 2026 12:52
@github-actions github-actions Bot added the pkg/analytics Includes changes to the `packages/analytics` directory label Jun 9, 2026
@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 1dc0f02
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6a280ca0df2f5e00087abbf5
😎 Deploy Preview https://deploy-preview-2409--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg/analytics Includes changes to the `packages/analytics` directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

await analytics.track() produces TS80007 because Analytics interface returns void instead of Promise<void>

1 participant