NorthwoodsSoftware / GoJS

JavaScript diagramming library for interactive flowcharts, org charts, design tools, planning tools, visual languages.
http://gojs.net
Other
7.8k stars 2.86k forks source link

Typings: copyToClipboard doesn't accept null #165

Closed dominic-simplan closed 2 years ago

dominic-simplan commented 2 years ago

According to the documentation, I can pass null to copyToClipboard in order to clear it. However, this is not reflected currently in the typings (we are using `stict: true in tsconfig)

Is: copyToClipboard(coll: Iterable<Part>): void; Should be; copyToClipboard(coll: Iterable<Part> | null): void;

Edit: Or the comment is wrong... Seems like I am getting an error if passing null: Cannot read property 'iterator' of null

simonsarris commented 2 years ago

Thank you for reporting this. We will definitely fix this in 2.2 (currently in alpha, about to go into beta), but for 2.1, could you potentially use

// @ts-expect-error

above the line? (Assuming you're on TypeScript 3.9 or higher)

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#-ts-expect-error-comments

simonsarris commented 2 years ago

This is fixed in GoJS 2.2 Beta: https://gojs.net/beta/

You can install it via npm i gojs@beta

2.2 will be out of Beta around the new year. We expect no more major changes, only documentation.

dominic-simplan commented 2 years ago

Thanks, for now I've worked around it by using the Non-null assertion operator. With @ts-expect-error, I am getting Unused '@ts-expect-error' directive. Not sure why.