wasp
wasp copied to clipboard
Use `strict: true` for TS for the SDK package
[!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):
strict: true |
strict: false |
You'll notice that the inferred return type is missing some of the type information, for example the identities being optional.
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
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