open-design-sdk icon indicating copy to clipboard operation
open-design-sdk copied to clipboard

fix Fontkit typing

Open jankuca opened this issue 4 years ago • 4 comments

The avocode/fontkit library is in plain JS and does not provide types.

This should fix the "Cannot find type definition file for 'avocode-fontkit'" error popping up in TS project builds when a project uses opendesign/sdk.

(WIP, needs to be tested)

jankuca avatar Jan 10 '22 13:01 jankuca

This doesn't build out of the box. Is this an issue with the code or the TypeScript config?

$ tsc --outDir dist --sourceMap --declaration --project ./tsconfig-build.json
src/local/system-font-manager.ts:290:39 - error TS7006: Parameter 'fontInfo' implicitly has an 'any' type.

290         fontCollection.fonts.forEach((fontInfo) => {
                                          ~~~~~~~~


Found 1 error.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 2
Command: /usr/local/bin/node
Arguments: /usr/share/yarn/lib/cli.js run build
Directory: /workspaces/open-design-sdk/sdk
Output:

info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

rhefner1 avatar Jan 11 '22 10:01 rhefner1

It is an issue with missing typing info, not TS config. I did not have time to test this PR yesterday so I just drafted it out.

The any has to be explicit here fontInfo: any for the error to disappear. Since the library does not have types, I think it is OK to do it this way for now.

jankuca avatar Jan 11 '22 12:01 jankuca

As a workaround, you can set "skipLibCheck": true in your tsconfig.json

xorb avatar Feb 21 '22 23:02 xorb

@xorb good workaround, but I'd love to fix this for real. Ping @petrbrzek @rychlis

rhefner1 avatar Mar 08 '22 22:03 rhefner1