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 error TS2314 on diagram function type #14

Closed
mikelax opened this issue Oct 22, 2021 · 2 comments · Fixed by #15
Closed

Typescript error TS2314 on diagram function type #14

mikelax opened this issue Oct 22, 2021 · 2 comments · Fixed by #15

Comments

@mikelax
Copy link

mikelax commented Oct 22, 2021

Overview

I am trying to use version 2.0.0 and I am getting a Typescript error when I try to build my project. The error is as follows:

node_modules/websequencediagrams/types/wsd.d.ts:33:83 - error TS2314: Generic type 'Array<T>' requires 1 type argument(s).

33     static diagram(description: string, style?: string, format?: string): Promise<Array<Buffer, string>>;

I get this error using both typescript 4.3.x and 4.4.x.

Fix

I think the fix is to make the Array take an implicit object of Buffer and string in the wsd.d.ts file.
I believe this resolves the issue:

static diagram(description: string, style?: string, format?: string): Promise<Array<{diagram: Buffer, mimeType: string}>>;
hildjj added a commit that referenced this issue Oct 23, 2021
@hildjj
Copy link
Owner

hildjj commented Oct 23, 2021

My goal is to have the types in the .js files be both legal jsdoc types as well as correct typescript types. I don't think that's possible here because jsdoc doesn't support tuples (see jsdoc/jsdoc#1703).

My work-around was to use a simple Array in jsdoc, and hand-edit the .ts file with the proper tuple type.

Will this work for you?

@mikelax
Copy link
Author

mikelax commented Oct 24, 2021

Hello @hildjj i think your initial goal would be great to have the types generated from jsdoc.

In this case I think your idea of (for now) hand editing the type file to solve this one case is correct.

Thank you for addressing!

@hildjj hildjj mentioned this issue Oct 24, 2021
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 a pull request may close this issue.

2 participants