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 1 year 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

https://github.com/wasp-lang/wasp/pull/2054 took care of some of the flags, but not all of them (e.g., the one which motivated this issue, strictNullChecks is still off). The remaining flags are already explicitly listed in the TS file and commented out.

There's also the problem of ensuring that mismatches between the user's and the SDK's tsconfig.json don't cause problems. This is covered by: https://github.com/wasp-lang/wasp/issues/1827#issuecomment-2133815538

sodic avatar May 27 '24 16:05 sodic

strictNullChecks was enabled in https://github.com/wasp-lang/wasp/pull/2360.

Just a few more to go! This one might be close: https://github.com/wasp-lang/wasp/issues/2056

sodic avatar Apr 11 '25 15:04 sodic