annotorious
annotorious copied to clipboard
The `AnnotoriousContext` doesn't use the `AnnotoriousContextState` type
Issue
The AnnotoriousContext is created using the auto-inferred type from the inline object:
https://github.com/annotorious/annotorious/blob/9188ea1d73911209dcd367734e7f45f5382950e3/packages/annotorious-react/src/Annotorious.tsx#L26-L36
However, there's the AnnotoriousContextState lying around unused: https://github.com/annotorious/annotorious/blob/9188ea1d73911209dcd367734e7f45f5382950e3/packages/annotorious-react/src/Annotorious.tsx#L14-L24
That makes the props obtained from the useContext(AnnotoriousContext) have the any type:
Also, it allows unsafe accessing of possibly missing properties:
Suggested solution
The Annotorious may become a generic provider accepting the type for the specific Annotator sub-type, like the ImageAnnotator:
https://github.com/annotorious/annotorious/blob/9188ea1d73911209dcd367734e7f45f5382950e3/packages/annotorious/src/Annotorious.ts#L20-L36
Oh - well, the intention was there ;-)