Skip to content

Conversation

m-kawafuji
Copy link

@m-kawafuji m-kawafuji commented Mar 10, 2025

PR Checklist

Please review the guidelines for contributing to this repository.

  • I am requesting to pull a topic/feature/bugfix branch (right side). In other words, not main.
  • I have run npm test against my changes and tests pass. (This PR only changes type definitions)
  • I have added tests to prove my fix is effective or my feature works. This can be done in the form of unit tests in test/unit/ or a new or altered demo in demo/. (This PR only changes type definitions)
  • I have added or edited necessary types and generated documentation (npm run docs), or no docs changes are needed.

Description

The options passed to Panzoom() and setOptions() aren't properly typed.
Becase of the use of Omit<Type> to omit force, The types for the options becomes Record<string | number, any>

Expected behavior

Invalid options passed to Panzoom() and setOptions() should be treated as type errors.

const panzoom = Panzoom(elem, {
  animate: 1, // error: Type 'number' is not assignable to type 'boolean | undefined'.
  noBind: "", // error: Type 'string' is not assignable to type 'boolean | undefined'.
});

Actual behavior

const panzoom = Panzoom(elem, {
  animate: 1, // works!
  noBind: "", // works!
});

I tweaked these two files, as the correction to the types.
demo/examples/PanzoomWithinPanzoom.tsx
demo/examples/Rotate.tsx

Fixes: #679

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