Skip to content

MountOptions is hand-mirrored from a private package with nothing guarding the drift #42

Description

@sidgaikwad

src/types.ts carries this warning:

https://github.com/unlayer/react-image-editor/blob/628b507/src/types.ts#L18-L20

// KEEP IN SYNC WITH packages/image-editor/src/index.ts in the unlayer
// monorepo — these mirror the private @unlayer/image-editor package's
// public API until they move into @unlayer/types.

MountOptions, ImageEditorInstance, ImageEditorEmbed and ImageEditorSaveResult are all hand-copied from a package this repo does not depend on. The only thing keeping them accurate is a code comment and a maintainer remembering.

Why this is worth a guard

The drift is silent in both directions and both are user-visible:

  • Option added upstream → not typeable here. Consumers get a type error passing a real, supported option and have to cast.
  • Option renamed/removed upstream → still accepted here, passed straight through createEditor, ignored at runtime. Nothing fails; the feature just doesn't work.
  • Instance method changedImageEditorInstance claims a method that no longer exists; editorRef.current.editor.foo() throws at runtime with a fully green typecheck.

Issue #25 (Features.imageEditor missing dock and corners) was exactly this class of bug — it reached users before it was noticed.

Options

  1. Finish the stated plan — move these into @unlayer/types (which is already a real dependency, currently pinned at 1.477.0) and delete the local copies. This is the comment's own "until".
  2. Add a CI drift check — if the private package publishes anything consumable, diff the two declaration sets in CI and fail on divergence.
  3. At minimum, add a runtime-shape test asserting ImageEditorInstance's method names against the live embed, so a rename surfaces as a red test rather than a support ticket.

Option 1 is the durable one; the comment already says that's the intent.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions