fermyon / spin-js-sdk

https://developer.fermyon.com/spin/javascript-components
Apache License 2.0
52 stars 18 forks source link

Top level `.d.ts` file containing all SDK types #158

Closed radu-matei closed 1 month ago

radu-matei commented 1 year ago

Currently, the SDK contains a mix of built-in types (such as utils.Router, spinSdk, or ResponseBuilder) and types that can be inspected in the TypeScript source.

This creates confusion when some types need to be explicitly imported, while other don't.

This issue asks for a type definition file that contains all the types ever used in the SDK, so all types would be imported from the type definition file.

cc @karthik2804

karthik2804 commented 1 year ago

Looking into it. Just a little bit confused on what you mean by types that can be inspected from TypeScript source.

radu-matei commented 1 year ago

Sorry, I meant the types that can be found in the sdk.ts source file in this repo.

karthik2804 commented 1 year ago

All the types are defined here https://github.com/fermyon/spin-js-sdk/tree/main/types/lib in this same repo (includes spinSdk and others). I will look to make it such that the types have to be explicitly imported.

Along those lines, there is a case of pure JS users where the spinSdk module will still be global level without any explicit imports.

One solution is to make it such that we move away from just providing a types file and make it an actual library with an implementation that wraps the internal types into implementations of its own that can be explicitly imported (this would require a little bit of restructuring of how things are currently done). I can look to make a simple PoC

karthik2804 commented 1 month ago

We now have a new SDK with much better type support.