NorthwoodsSoftware/GoJS

Typings: copyToClipboard doesn't accept null

dominic-simplan opened this issue · 3 comments

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

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

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.

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.