Skip to content

test: trip when the mirrored editor types move upstream - #63

Open
sidgaikwad wants to merge 1 commit into
unlayer:mainfrom
sidgaikwad:test/types-drift-tripwire
Open

test: trip when the mirrored editor types move upstream#63
sidgaikwad wants to merge 1 commit into
unlayer:mainfrom
sidgaikwad:test/types-drift-tripwire

Conversation

@sidgaikwad

Copy link
Copy Markdown

Partially addresses #42 — please read the caveat before merging.

What this does

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 that move happens, the local copies silently become a second, diverging source of truth. That's exactly how #25 (Features.imageEditor missing dock/corners) reached users.

test/typesDrift.test.ts scans the installed @unlayer/types declarations and fails the moment any mirrored name appears there:

AssertionError: @unlayer/types now exports JSONTemplate. Delete the mirrored
declaration(s) from src/types.ts and re-export from @unlayer/types instead,
then drop the name(s) from this test.

(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.0 exports none of the four.)

The KEEP IN SYNC comment 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-editor package 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:

  1. Move the types into @unlayer/types — the durable fix, and the comment's own stated intent. Only Unlayer can publish that.
  2. CI drift check against the private package — needs access this repository doesn't have.
  3. Runtime shape assertion — I chose not to add one. It would mean loading the live CDN embed in CI, which makes the suite network-dependent and flaky for a check that only fires on a rename.

So this closes the cheap half and leaves the real fix as yours. Happy to do the @unlayer/types migration in a follow-up if you publish the types there.

Tests 47, coverage still 100%; lint, typecheck, build clean.

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.
@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

@sidgaikwad is attempting to deploy a commit to the Unlayer Team on Vercel.

A member of the Team first needs to authorize it.

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