We should measure the performance impact of doing this first. However, based on issues, it seems fairly clear that the Babel-based TypeScript support that we have now is too limited. @babel/preset-typescript
doesn't enable all of the language features that TSC does, e.g. decorators, class properties, optional chaining, etc. This causes confusion for people.
We could either attempt to match the features that TSC supports in our default config, or just run TSC first, and then Babel like we did in v1. The main issue is that when you add a custom Babel config, you'd need to re-create our default yourself, which might also be confusing.
The action items here are:
@parcel/transformer-typescript-tsc
for .ts
and .tsx
files instead of babel, and measure the performance impact.I wonder if this is the best criteria for deciding if TSC is OK as the default. Mainly, I would be surprised if there are actually any large TypeScript projects that didn't have a tsconfig / use TSC already.
Having a tsconfig and using TSC for compilation are two different things. For example, you could have a tsconfig for type checking and editor integration, but use Babel for compilation. This is how popular tools like create-react-app and Next.js work.
I prefer tsc
since it is "the main typescript" compiler. Build time is not a concern for me. I have never had any compiling-time issues in JavaScript. When you consider the time it takes to build a native application using LLVM for example, tsc
vs babel
becomes just negligible. You should not sacrifice the quality of the code and development just to cut the build time!
tsc
has "incremental building" and "watch mode" built-in, which can increase the build time.
tsc
- Compiling TypeScript as nature intended.
- Switch a large TypeScript project to use
@parcel/transformer-typescript-tsc
for.ts
and.tsx
files instead of babel, and measure the performance impact.
Suppose that we tried this on a moderately sized project and it failed. Is it worth filing bugs now, or if/when tsc
is the default?
Is it worth filing bugs now
Yes
Most helpful comment
I prefer
tsc
since it is "the main typescript" compiler. Build time is not a concern for me. I have never had any compiling-time issues in JavaScript. When you consider the time it takes to build a native application using LLVM for example,tsc
vsbabel
becomes just negligible. You should not sacrifice the quality of the code and development just to cut the build time!tsc
has "incremental building" and "watch mode" built-in, which can increase the build time.