Use a subset of `strict: true` in the SDK
sodic opened this issue · comments
Building the SDK generates two kinds of files:
- JavaScript files (
.js
) used in the runtime. - Declaration files (
.d.ts
) used for type support by the IDE.
Declaration files (d.ts
) are subject to our user's tsconfig.json which is more strict than sdk/wasp/tsconfig.json used to build the SDK. This results in the SDK's declaration files having type errors when looked at from the user's perspective (e.g., during go-to-definition jumps).
We've avoided using strict: true
in the tsconfig.json we use for building the SDK due to legacy reasons (old JS or improperly typed code that still works).
This is not a big problem, but definitely isn't ideal:
- Our SDK is deemed "wrong" by our own system, which is a little unprofessional.
- These type errors truly are type errors (they're not false-positives). Not compiling the SDK in strict mode prevents us from catching them. In other words, a small part of legacy code disqualifies the entire SDK from reaping the full benefits of TypeScript.
Since the strict: true
compiler flag is a shorthand for multiple more specific flags, we should activate all the "subflags" that don't require a major refactor of the SDK. After that's done, we can tackle #1938 and change whatever we need to go full strict mode (this will probably take some time).