Skip to content

addons: declare the optional arguments of installGPTEventListeners and tryIdentifyFromParams - #379

Merged
mosherBT merged 1 commit into
masterfrom
mo/fix-addon-type-declarations
Oct 30, 2026
Merged

mosherBT merged 1 commit into
masterfrom
mo/fix-addon-type-declarations

Conversation

@MO-Thibault

Copy link
Copy Markdown
Contributor

Why

installGPTEventListeners and tryIdentifyFromParams accept optional arguments, and the README documents calling them with those arguments (README "GPT event listeners" and "Call tryIdentifyFromParams SDK API"). Their module augmentations declared them as () => void, so TypeScript consumers copying the documented calls get a compile error:

error TS2554: Expected 0 arguments, but got 1.   // sdk.installGPTEventListeners({ impressionViewable: [...] })
error TS2554: Expected 0 arguments, but got 2.   // sdk.tryIdentifyFromParams("email_md5", "c2")

JavaScript and script-tag users are unaffected (types only). Found while type-checking the product docs' examples against the SDK.

What Changed

  • lib/addons/gpt.ts: installGPTEventListeners: (eventSpec?: GptEventSpec) => void, matching the implementation's signature.
  • lib/addons/try-identify.ts: tryIdentifyFromParams: (key?: string, prefix?: string) => void, matching the implementation's signature.

How to Test

  • pnpm build-lib, tsc -b browser, pnpm test (36 suites, 680 tests) and pnpm format all pass locally with no other changes.

  • A TypeScript consumer calling both methods with and without arguments fails on master with the two errors above and compiles cleanly with this change.

  • Tested

  • Docs updated (not needed: no behavior change; the README already documents these arguments)

Notes

  • Breaking change (no: argument lists only widen, all optional)
  • Requires release (the fix reaches TypeScript users on the next published version; no urgency)

🤖 Generated with Claude Code

…d tryIdentifyFromParams

Both methods accept optional arguments (eventSpec; key and prefix), and the README
documents calling them with those arguments, but their module augmentations declared
them as () => void. TypeScript consumers copying the documented calls got
"Expected 0 arguments". Types only; no runtime change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MO-Thibault
MO-Thibault requested review from a team as code owners October 30, 2026 17:34
@mosherBT
mosherBT merged commit 33627fa into master Oct 30, 2026
7 checks passed
@mosherBT
mosherBT deleted the mo/fix-addon-type-declarations branch October 30, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants