tjek / tjek-js-sdk

Tjek JavaScript SDK for the browser and Node.js.
18 stars 4 forks source link

Publish TypeScript declarations to NPM #246

Closed boserup closed 2 months ago

boserup commented 2 months ago

We're currently using the SDK in a TypeScript project, and noticed that TypeScript types are not available via NPM. It would greatly improve our experience if the type declarations were either included in the package itself or published directly to NPM.

klarstrup commented 2 months ago

Hi I've had a go at implementing this and it is now published on the @experimental tag, please try that out and let me know if it fulfills your needs.

klarstrup commented 2 months ago

Types are published as of verso-browser@1.4.0, @tjek/sdk@0.16.0, shopgun-sdk@4.22.0 and incito-browser@2.6.0. Let me know if you need anything improved in them

boserup commented 2 months ago

@klarstrup Thank you! I quickly tested it, and can see most types were resolved correctly from shopgun-sdk. We manually fixed the rest to import directly from the kits: import type { V2Hotspot } from 'lib/kits/core/index'

klarstrup commented 2 months ago

Oh I would prefer you stay out of those extraneously declared modules, soon those won't be exposed. I've published a new version that exposes those API model types properly.

boserup commented 2 months ago

That makes sense. We were able to resolve V2Hotspot from shopgun-sdk, and some of the other types we used. However PagedViewer from PagedPublicationKit is still only available via the kit-import.

Screenshot 2024-09-09 at 13 02 23

The same goes for PagedPublicationEventTracking (lib/kits/paged-publication/event-tracking).

Those two are the only remaining unresolved types we are using as of today.

klarstrup commented 2 months ago

I would suggest that for the time being you derive those type from the related classes(i.e. ReturnType<IncitoPublicationBootstrapper["createViewer"]> and ReturnType<IncitoPublicationBootstrapper["createViewer"]>['_eventTracking']) while we at Tjek figure out the long-term approach for the type exports of this package.