I'm currently working on a React project using typescript and the bundler ParcelJs. I'm using a tsconfig.json
file to configure typescript but for some reason that I don't know, Parcejs doesn't consider it ignoring all the errors on build.
For example, I wrote this code that is invalid in typescript:
const message: number = "Hello world!";
My eslint trigger this error correctly:
Type '"Hello world!"' is not assignable to type 'number'
But when I build this file using parcel ./src/index.tsx
it compiles without errors.
According to the official documentation and this issue I need to declare a Validator in the ParcelJs configuration file .parcelrc
:
{
"extends": "@parcel/config-default",
"validators": {
"*.{ts,tsx}": ["@parcel/validator-typescript"]
}
}
The parcel validator need to be installed in package.json
:
...
"dependencies": {
"@parcel/validator-typescript": "2.0.0-nightly.112",
...
So at the end my project structure looks like this:
├── .cache/
├── dist/
├── src/
│ ├── index.tsx
├── .parcelrc
├── package.json
├── tsconfig.json
Note:
- If I write invalid json data in the
.parcelrc
file, ParcelJs still succeeds to build without any problem as if the configuration file was ignored
Does anyone have an idea how to get ParcelJs to take into account the typescript configuration?