Skip to content

Fix packed web-host typecheck when @powersync/web is installed - #55

Merged
darekaze merged 2 commits into
mainfrom
drkz/fm-ps-lynx-017-web-host-peer-types-9b06
Sep 10, 2026
Merged

darekaze merged 2 commits into
mainfrom
drkz/fm-ps-lynx-017-web-host-peer-types-9b06

Conversation

@darekaze

Copy link
Copy Markdown
Member

Closes #50.

Packed powersync-lynx/web-host failed TypeScript when the optional peer @powersync/web was installed: the unused @ts-expect-error on the literal dynamic import in src/web-host/attach.ts became TS2578. Native consumers (peer absent) still need that import to typecheck.

Approach

Keep the literal import("@powersync/web") and source-only distribution. Replace @ts-expect-error with a narrow @ts-ignore so both dependency states compile:

  • Native / peer absent: still suppresses TS2307.
  • Web / peer present: unused @ts-ignore is not an error.

The Host helper continues to hide optional-peer typing behind PowerSyncWebModule / attach. @powersync/web stays an optional peer only — it is not added to the native runtime graph.

Validation

Added two packed-consumer configurations and a release check:

  • scripts/packed-consumers/native — packed tarball, no @powersync/web, typechecks the Client barrel and powersync-lynx/web-host
  • scripts/packed-consumers/web — packed tarball + @powersync/web@2.3.0, imports powersync-lynx/web-host

pnpm check-packed-consumers / test/packed-consumers.test.ts also assert the factory stays importable and that esbuild still sees the literal Web SDK specifier.

Out of scope

Does not implement #52.

Open in Web Open in Cursor 

cursoragent and others added 2 commits September 10, 2026 02:03
Replace unused @ts-expect-error on the literal @powersync/web import
with a narrow @ts-ignore so packed native and web consumers both
compile. Add packed-consumer typecheck configurations and a release
check. Closes #50.

Co-authored-by: Darwin <darekaze@users.noreply.github.com>
Keep the comment from matching a real @ts-expect-error directive.

Co-authored-by: Darwin <darekaze@users.noreply.github.com>
@cursor

cursor Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review (FM-PS-LYNX-017 / Closes #50)

Verdict: Approve for merge

Reviewed against the #50 acceptance list (Issues API is 403 for this integration; criteria taken from the filed-issue prompt that opened this PR). Base 5225ad1. CI check is green, including packed native and web consumers typecheck optional-peer web-host.

No High / release-blocker in this diff. Did not expand into #38 / #51 / #53 (none of those block this typing fix).

Acceptance

# Requirement Result
1 Packed native consumer typechecks without @powersync/web Met. scripts/packed-consumers/native imports the Client barrel and powersync-lynx/web-host; install uses --config.auto-install-peers=false and asserts the peer is absent (and not added to the library graph).
2 Packed Web consumer imports powersync-lynx/web-host and typechecks with @powersync/web@2.3.0 Met. scripts/packed-consumers/web + exact 2.3.0 pin.
3 Factory remains importable; literal Web SDK import remains bundler-resolvable Met. assertFactoryImportable + esbuild external: ["@powersync/web"] plus a source-level literal-import / no-@ts-expect-error check.
4 pnpm typecheck / lint / test; packed-consumer configs in release validation Met. Script pnpm check-packed-consumers + test/packed-consumers.test.ts (picked up by pnpm test / CI). Not added to publish-dry-run — acceptable; CI pnpm test is the release gate.

Core change

Narrow @ts-ignore TS2307 on the literal import("@powersync/web") is the issue-allowed smallest fix. Unused @ts-expect-error is TS2578 when the peer is present; unused @ts-ignore is not. Specifier stays a string literal (bundlers). Runtime typing still goes through PowerSyncWebModule / attach. @powersync/web stays optional-peer-only.

I independently confirmed the packed-consumer skipLibCheck: true does not make this a false green: TypeScript still typechecks imported .ts under node_modules. A probe with the old @ts-expect-error + peer present still fails TS2578; @ts-ignore passes. The comment wording avoids a real @ts-expect-error directive so the regression regex does not false-positive.

Tests

Adequate for #50. CI ran the packed typecheck (~4s on the Actions runner). Static attach.ts assertions catch a revert to @ts-expect-error even if someone later weakens the consumer configs.

Residuals (not blocking)

  • Medium: @ts-ignore can hide a future error on that one import line if the peer is present. Accepted by the issue; the following line still casts through PowerSyncWebModule.
  • Low: packed-consumer test does two registry installs and has no explicit timeout. Passed here; worth a 60s timeout if CI ever flakes on a cold npm.
  • Out of scope: consumer allowImportingTsExtensions / TS5097 (016 packaging note) is a docs/config requirement, not this unused-directive bug.

No merge from this review.

@darekaze
darekaze merged commit 63e8cda into main Sep 10, 2026
1 check passed
@darekaze
darekaze deleted the drkz/fm-ps-lynx-017-web-host-peer-types-9b06 branch September 10, 2026 02:19
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.

[High][0.1.0 blocker] Packed web-host entry fails typecheck when optional Web peer is installed

2 participants