Discussed in https://github.com/denoland/deno/discussions/8549
Originally posted by kitsonk November 30, 2020
Instead of --no-check
consider type checking TypeScript as an opt-in with a --check
option.
The core team has discussed this and reviewed the feedback from the community. Based on that, we are going to move forward with the following:
- The
--check
flag will be implemented for the appropriate subcommands. This will use the built-in tsc
for type checking and use tsc
for the emit (except for bundles where we will use swc
). We may in the future use swc
for the emit here as well. This is basically the current default behaviour of Deno.
- The
--no-check
flag will be deprecated and issue a warning that it is deprecated. The behaviour will not change from its current for now.
- The default behaviour of the command line will be changed so that the code is not type checked and emitted using
swc
(this is basically the behaviour of --no-check
now).
We will raise the PRs necessary to implement this and tentatively aim to introduce this in 1.13.
Why are you doing this?
The goal of the Deno CLI is to be a fun and productive scripting language. A user should be able to hack on some code and quickly see the results of their endeavour. The more "hurdles" that are in the way, the less fun and productive the experience becomes. We β€οΈ TypeScript, we want people to use TypeScript more and more, but there are two major challenges with that:
- Type checking is relative slow and expensive. We have tried (almost) everything to speed it up (see: #5432) but a relative small program still takes a second or two to type check, while just transpiling the TypeScript with
--no-check
takes under 100ms.
- Deno terminates if it encounters a type check diagnostic. That is on us. We should have maybe always treated them as warnings and still executed the output anyways, but we didn't. We could of course change that now, but the problem then is the point above. We don't feel there is a huge amount of value to users to just address this point.
While on the surface it might seem like we are "watering" down Deno, we are motivated to make it easier to use Deno. If you are just starting out, maybe not having used TypeScript in strict mode before, or are just trying to hack a few lines of TypeScript and don't have all of your type annotations right, or you have imported a 3rd party library whose globals conflict with another 3rd party library, you have to spend all your time sorting that out to just find out if your code runs. Again, that isn't fun for anyone and certainly isn't productive.
Also, we have tried to put a lot of effort into the language server, and realistically that is where most people type check their code anyways, in their editor, which means to the majority of people type checking is not the default need they have when running on the command line. It is something they need as a final check, maybe in their CI, maybe before they commit, not every time they want to see if the code runs.
So, we acknowledge that in the discussion there wasn't overwhelming broad support for this, but we think we need to do this not for those already using Deno on a daily basis, but for those experimenting with Deno and TypeScript.
feat cli maybe 2.0