-
Notifications
You must be signed in to change notification settings - Fork 406
Description
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe it
Right now it does seem possible to turn off type-checking with SWC if it is enabled in the nest-cli.json.
Take this config:
{
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"typeCheck": true,
"builder": "swc"
}
}
Running nest start
starts the TSC TypeChecker and when done builds with swc
which is what I expect. If i now use nest build --type-check=false
(also tried without =
) the type check will start anyway. This seems to be a somewhat specific handling for this flag only, as nest start --builder=tsc
would start the build process using tsc
instead, ruling over my nest-cli.json.
Describe the solution you'd like
The easiest solution would be to allow --type-check
(and maybe other boolean-like flags) to also be disabled by the CLI via an (optional) argument. I've tried finding my way through this repository but couldn't quite figure out where this logic happens.
Teachability, documentation, adoption, migration strategy
User could add an additional, optional parameter after the --type-check
. I'd suggest an interface like this:
nest build # fallback to config
nest build --type-check # type-checks
nest build --type-check true # type checks
nest build --type-check false # does not type-check, even if config is `true`
as this would not touch the current behavior there shouldn't be any issues with just releasing this as an minor issue.
What is the motivation / use case for changing the behavior?
I have two motivations for this change, which boil down to the same reason: speed and efficiency.
The first use case is in our CI: We're already type-checking our whole monorepo earlier in the CI process so it's not necessary to do this again when building NestJS. Removing the unnecessary type check here will speed up the process by about 20s.
Our second use case is swagger.json generation. If our Nest Application is started with a specific environment variable it will only output the swagger.json and then exit. This is needed to generate the OpenAPI Clients based on this swagger file. At this time in the process we don't really care if the types are valid (cause either it is mid-development or they've already been checked before in the CI) so we would love to also skip type checking there as well.