Skip to content

fix: patch.create type declaration (TS1016) - #20

Merged
raphi merged 1 commit into
mainfrom
fix/patch-create-types
Oct 24, 2026
Merged

raphi merged 1 commit into
mainfrom
fix/patch-create-types

Conversation

@raphi

@raphi raphi commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes a TypeScript error in the published type declarations (2.2.0 to 2.3.0). Version 2.3.1.

Problem

patch.create has two overloads. The second declared a required parameter after an optional one:

create(update: AtLeastOne<PKPatchUpdate>, opts?: PKPatchUpdateOptions, origin: PKResult)

Any TypeScript project with skipLibCheck: false fails to compile as soon as it imports @placekit/client-js (directly or through @placekit/autocomplete-js / @placekit/autocomplete-react):

node_modules/@placekit/client-js/dist/placekit.d.ts(23,7): error TS1016: A required parameter cannot follow an optional parameter.

Changes

  • src/placekit.d.ts: opts?: PKPatchUpdateOptions -> opts: PKPatchUpdateOptions | undefined in that overload. Matches the runtime signature create(update, opts = {}, origin): callers can still pass undefined or an object as opts.
  • README.md: missing comma in the "fixing an existing location" example.
  • rollup.config.js: JSON import uses with instead of assert (assert is rejected by Node 22; supported by Node 18.20+/20.10+, CI runs Node 20).
  • Version 2.3.1. No runtime code change apart from the version in the User-Agent string.

Testing

Consumer project (strict, skipLibCheck: false) calling every patch.create form (create(record), create(record, opts), create(partial, opts, origin), create(partial, undefined, origin), create(partial, {}, origin)) plus search:

TypeScript 2.3.0 this PR
4.9 TS1016 clean
5.0 TS1016 clean
5.6 TS1016 clean

Also checked on TypeScript 4.5, 5.9 and the 7.0 native preview, strict and non-strict, exactOptionalPropertyTypes, and node / node16 / bundler resolution: diagnostics differ only by the removed TS1016 line. Built output vs 2.3.0: only the version banner, the User-Agent version and this d.ts line differ.

With skipLibCheck: true, diagnostics are identical before and after, including invalid calls that must stay rejected (partial update without origin).

npm run lint, npm run build and npm test (41/41 on Node 20, as in CI) pass.

Note: npm test (node --test ./src) does not run on Node 22 (directory argument, and the tests assign the read-only global navigator). Unchanged here; CI uses Node 20.

🤖 Generated with Claude Code

The second overload declared a required `origin` after an optional
`opts`, a TS1016 error for consumers with skipLibCheck false.
`opts` is now `PKPatchUpdateOptions | undefined`, matching the
runtime signature. Also fixes the README example (missing comma) and
the rollup JSON import (`assert` -> `with`, rejected by Node 22).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raphi raphi self-assigned this Oct 24, 2026
@raphi
raphi merged commit c05ecdc into main Oct 24, 2026
1 check passed
@raphi
raphi deleted the fix/patch-create-types branch October 24, 2026 14:39
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.

1 participant