Skip to content

Add "DOM" to tsconfig.json's lib array for browser-facing wallet/signing modules #119

Description

@meshackyaro

Description

tsconfig.json's compilerOptions.lib is ["ES2022"] only — no "DOM". Yet src/stellar/signing.ts (if (typeof window === 'undefined' || !(window as any).freighter)), src/wallet/albedo.ts (if (typeof window === 'undefined') { return null; } return (window as any).albedo), and src/wallet/freighter.ts (three separate window references) all reference the global window identifier directly. Without the DOM lib, TypeScript has no declaration for window at all, so tsc --noEmit fails with TS2304: Cannot find name 'window' at every one of these call sites — even though the code is deliberately written to be safe in a non-browser environment via the typeof guard, the guard itself doesn't compile.

Component

SDK

Difficulty

🔴 Hard

Tasks

  • Decide the isomorphic-build strategy: add "DOM" to the shared tsconfig.json's lib (simplest, but makes all of src/ see DOM globals even where inappropriate), or isolate browser-only files (signing.ts, wallet/*.ts) under a separate tsconfig with its own lib array
  • Apply the chosen fix
  • Re-run tsc --noEmit to confirm the window-related errors are gone
  • Confirm tsup.config.ts's platform: 'neutral' build still produces correct output for both Node and browser consumers after the change

Acceptance Criteria

  • tsc --noEmit reports no undeclared-window errors
  • The Node-only build path is unaffected by newly-visible DOM globals (no accidental use of browser-only APIs outside the wallet/signing modules)

Estimated Time

2-3 days

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions