Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript type declarations #204

Closed
tmladek opened this issue Feb 14, 2022 · 7 comments
Closed

TypeScript type declarations #204

tmladek opened this issue Feb 14, 2022 · 7 comments

Comments

@tmladek
Copy link

tmladek commented Feb 14, 2022

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!

@rsimon
Copy link
Member

rsimon commented Feb 14, 2022

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 :-)

@tmladek
Copy link
Author

tmladek commented Feb 14, 2022

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 ;)

@rsimon
Copy link
Member

rsimon commented Feb 14, 2022

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 :-)

@n0mn0m
Copy link

n0mn0m commented Feb 14, 2022

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

@viconx98
Copy link

+1 Would be nice to have type definitions!

@CodingJinxx
Copy link

CodingJinxx commented Aug 3, 2023

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 };
}

@rsimon
Copy link
Member

rsimon commented Oct 1, 2023

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 rsimon closed this as completed Oct 1, 2023
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

No branches or pull requests

5 participants