wasp icon indicating copy to clipboard operation
wasp copied to clipboard

Use `strict: true` for TS for the SDK package

Open infomiho opened this issue 10 months ago • 1 comments

[!IMPORTANT] Edit by @sodic, before tackling this, take care of:

  • #2010
  • #1827

The d.ts file are generated incorrectly if we use inferred function return type to define a type.

If I write a complex function like createAuthUser that does some data transformation, I'd like to use typeof to infer the final return value. Something like this:

type AuthType = ReturnType<typeof createAuthUser>

function createAuthUser() { ... }

Now, let's check the generate d.ts files for this example (the strict one being the expected type):

Screenshot 2024-04-04 at 16 21 04
strict: true
Screenshot 2024-04-04 at 16 21 12
strict: false

You'll notice that the inferred return type is missing some of the type information, for example the identities being optional.

infomiho avatar Apr 04 '24 14:04 infomiho