test: trip when the mirrored editor types move upstream - #63
Conversation
src/types.ts hand-copies MountOptions, ImageEditorInstance, ImageEditorEmbed and ImageEditorSaveResult from the private @unlayer/image-editor package, with a comment saying it does so "until they move into @unlayer/types". Nothing enforced the "until". Once the move happens the local copies silently become a second, diverging source of truth — which is how a missing dock/corners reached users in unlayer#25. Add a tripwire that scans the installed @unlayer/types declarations and fails the moment any mirrored name appears there, with a message saying to delete the local copy and re-export instead. This is deliberately not a full drift check. Detecting the private package changing underneath us needs access this repository does not have, so that half stays a human responsibility — now at least written down next to the declarations.
|
@sidgaikwad is attempting to deploy a commit to the Unlayer Team on Vercel. A member of the Team first needs to authorize it. |
|
Please add the Node type configuration needed by this test. typecheck currently fails on node:fs, node:path, and process |
test/typesDrift.test.ts reads the installed @unlayer/types declarations, so it imports node:fs and node:path and calls process.cwd(). None of that typechecked: @types/node was never a root dependency, and tsconfig's "types" array listed only vitest/globals, which excludes the Node globals. Add @types/node (pinned exact, 24.10.9 — matching the demo's pin) and add "node" to the types array. Both halves are required: with the package installed but "node" absent from the array, tsc still reports TS2591 for all three. This passed locally for me because a stray @types/node in a parent directory of my checkout was being picked up by TypeScript's upward resolution. Verified in a clean tree outside that path.
|
Fixed in Why my local typecheck passed: there is a stray Exactly the three you named. The fix — both halves are required:
Verified in the isolated tree that installing the package alone is not enough: with One thing worth a look in the diff. 47 tests, coverage still 100%, lint/typecheck/build clean. One judgement call I would like your view on: adding |
Partially addresses #42 — please read the caveat before merging.
What this does
src/types.tshand-copiesMountOptions,ImageEditorInstance,ImageEditorEmbedandImageEditorSaveResultfrom the private@unlayer/image-editorpackage, with a comment saying it does so "until they move into@unlayer/types". Nothing enforced the "until".Once that move happens, the local copies silently become a second, diverging source of truth. That's exactly how #25 (
Features.imageEditormissingdock/corners) reached users.test/typesDrift.test.tsscans the installed@unlayer/typesdeclarations and fails the moment any mirrored name appears there:(That output is from deliberately adding a name that does exist upstream, to prove the tripwire fires — it passes as-is today, since
@unlayer/types@1.477.0exports none of the four.)The
KEEP IN SYNCcomment now points at the test, so the enforcement is discoverable from the declarations.What this deliberately does NOT do
It does not detect the private
@unlayer/image-editorpackage changing underneath you — the more dangerous direction, where a renamed instance method typechecks fine and throws at runtime.Of the three options in the issue:
@unlayer/types— the durable fix, and the comment's own stated intent. Only Unlayer can publish that.So this closes the cheap half and leaves the real fix as yours. Happy to do the
@unlayer/typesmigration in a follow-up if you publish the types there.Tests 47, coverage still 100%;
lint,typecheck,buildclean.