Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow --type-check to be set to false and override nest-cli.json #2796

Open
1 task done
dunklesToast opened this issue Nov 13, 2024 · 2 comments
Open
1 task done

Allow --type-check to be set to false and override nest-cli.json #2796

dunklesToast opened this issue Nov 13, 2024 · 2 comments
Labels

Comments

@dunklesToast
Copy link

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 tscinstead, 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.

@dunklesToast dunklesToast changed the title Allow --type-check to be set to false and override nest-cli.json Allow --type-check to be set to false and override nest-cli.json Nov 13, 2024
@micalevisk
Copy link
Member

micalevisk commented Nov 13, 2024

we have a naming convention for the disabled version of a boolean flag. For example: --no-flat and --no-spec from the generate command

So I'd suggest --no-type-check instead

@dunklesToast
Copy link
Author

Alright - did not knew that. Maybe then I can check again if I can implement this myself as adding a whole new flag seems to be easier doable as to add arguments. If you find the feature idea useful and have no objections I'd begin working on it and if done would create a PR. Would that work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants