annotorious icon indicating copy to clipboard operation
annotorious copied to clipboard

TypeScript type declarations

Open tmladek opened this issue 3 years ago • 4 comments

I'm using annotorious in a TypeScript project, so I'd like to type check my interactions with the annotorious API also.

However, this repo doesn't contain any type declaration files, and I wasn't able to find any npm package that would provide them either (e.g. the auto-suggested @types/recogito__annotorious).

Are there any plans on adding types?

Would you accept a pull request containing type declarations?

Thanks in advance!

tmladek avatar Feb 14 '22 12:02 tmladek

Yes, I'd definitely welcome that! However, not being a TS-developer myself, I'm not sure about the best approach. There was a discussion recently on the Gitter chat about posting type definitions for Annotorious to definitelytyped and that this would be somehow preferable? For lack of any knowledge & qualified opinion around TS-enabling Annotorious, I'm open to either option, though :-)

rsimon avatar Feb 14 '22 13:02 rsimon

posting type definitions for Annotorious to definitelytyped and that this would be somehow preferable?

Ah! That's probably right, if only because of the QA via the merge request approval process :) (To be honest, I've only ever written type declarations for software I've authored, so I completely forgot about definitelytyped.)

I'll take a look at that then - or if anyone's ahead of me, feel free to step up ;)

tmladek avatar Feb 14 '22 16:02 tmladek

I'm CC-ing in @n0mn0m: we talked about TS type definitions & definitelytyped. Let me know if there's anything I can do to help :-)

rsimon avatar Feb 14 '22 17:02 rsimon

👋 @tmladek I've been using annotorious in a project with Typescript/React for a few months now.

I've hacked together a custom definition file that I'm using right now and keep it in /src/@types/annotorious.d.ts, but that's not in a state I can share it right now.

I was talking with @rsimon about adding types in definitelytyped for annotorious (as linked above). I probably won't have time till sometime next month to do anything serious, but my thought was to use dts-gen to create an initial definition file. From there compare that with what I've hacked together over the last few months and actually replace what I have. Run our test suite and try out the definition file in the project. Once that was working well move into getting the definitions upstreamed to definitelytyped.

That said there are plenty of approaches and if you want to get started on something I'd be happy to collaborate/assist as time permits. Let me know how I can help out happy to do reviews, test definition files in our project etc.

n0mn0m avatar Feb 14 '22 21:02 n0mn0m

+1 Would be nice to have type definitions!

viconx98 avatar Nov 21 '22 18:11 viconx98

You can trick typescript into ignoring untyped modules

See this article here: https://kamranicus.com/tricking-typescript-into-typing-untyped-javascript-modules/

Here is how i did it for annotorious

recogito__annotorious.d.ts

declare module "@recogito/annotorious" {
    import { Annotorious } from "@recogito/annotorious";

    export { Annotorious };
}

CodingJinxx avatar Aug 03 '23 12:08 CodingJinxx

Closing this issue, as there won't be any TS declarations for Annotorious v2.x. Annotorious v3 is almost ready to go, and is written entirely in TypeScript. (It's now a separate branch in this repo.)

rsimon avatar Oct 01 '23 08:10 rsimon