parcel-plugin-typescript
parcel-plugin-typescript copied to clipboard
Type-checking errors aren't reported
Since there are no instructions for running the plug-in within parcel I assume it is supposed to work automatically - is that right? - but for me it doesn't.
My parcel --version is 1.9.0 but during installation I'm told "npm WARN [email protected] requires a peer of parcel-bundler@^1.9.0 but none is installed. You must install peer dependencies yourself."
Any ideas? I installed both with --global, then tried reinstalling parcel-bundler and parcel-plugin-typescript with --save-dev; this time I got v1.9.1 and the warning message did not appear, but when running .\node_modules\.bin\parcel there is no sign that the plugin is running, e.g. no type errors.
Other warnings did appear:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
What do you mean by "it doesn't work"? Do you get any errors, any crashes? Or you don't get a behaviour you expect?
The warnings are pretty self-explanatory :
WARN [email protected] requires a peer of parcel-bundler@^1.9.0 but none is installed. You must install peer dependencies yourself
It means you need to have parcel-bundler installed and it should respect the semver range ^1.9.0. If it is installed please open an issue open the npm repo. Also check you are using the parcel-bundler package and not parcel.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
It means the optional dependency fsevents cannot be installed (and it tells you it only works on macOS ("os":"darwin")). Because it is optional you don't have to worry about it. This is a Parcel dependency.
Do you get any errors, any crashes?
No.
Or you don't get a behaviour you expect?
I expect type checking in Parcel and none occurs.
you need to have parcel-bundler installed and it should respect the semver range ^1.9.0
Isn't v1.9.0 and v1.9.1 part of that range?
Isn't v1.9.0 and v1.9.1 part of that range?
Yes
I expect type checking in Parcel and none occurs.
Please provide a reproduction
Did you try using --no-cache?
Repro:
(1) Create an empty folder and add this index.html file:
<!DOCTYPE html><html><body>Types?<script src="error.tsx"></script></body></html>
(2) Create an error.tsx file with type error(s) (note: same thing happens with .ts extension)
var x:number="Fail!"; document.body.innerHTML=x;
(3) install and run (Windows 10)
npm init -f
npm install typescript --save-dev
npm install parcel-bundler --save-dev
npm install parcel-plugin-typescript --save-dev
.\node_modules\.bin\parcel --version
.\node_modules\.bin\parcel --no-cache
(4) notice lack of type checking
PS C:\Dev\empty> .\node_modules\.bin\parcel --version
1.9.2
PS #C:\Dev\empty> .\node_modules\.bin\parcel --no-cache
Server running at http://localhost:1234
√ Built in 1.91s.
Awesome, that's perfect, thanks. Will check ASAP.
i have same problem as @qwertie parcel not reporting ts errors, while i have a "type-check": "tsc" script which returns a bunch of errors.
Using
typescript 2.9.2
parcel-bundler 1.9.1
parcel-plugin-typescript 1.0.0
windows10 VSCode
I always get a pass when using this plugin when tsc reports errors
If it helps I get this each time:
Server running at http://localhost:1234
⚠️ Unexpected token }
at unexpected (/Users/nikos/WebstormProjects/youtube-space-invaders/node_modules/json-parser/index.js:121:9)```
I receive the exact same error while using typescript.
yarn run v1.7.0
$ rimraf ./dist && rimraf ./cache && parcel ./public/index.html
Server running at http://localhost:1234
✨ Built in 7.21s.
⚠️ Unexpected token }
at unexpected (.../node_modules/json-parser/index.js:121:9)
at expect (.../node_modules/json-parser/index.js:115:5)
at parse_object (.../node_modules/json-parser/index.js:140:5)
at walk (.../node_modules/json-parser/index.js:91:14)
at parse_object (.../node_modules/json-parser/index.js:148:33)
at walk (.../node_modules/json-parser/index.js:91:14)
at Object.parse (.../node_modules/json-parser/index.js:55:16)
at Object.parse (.../node_modules/comment-json/lib/parse.js:8:17)
at Object.
@QuantumInformation Fixed it by adding: "parcelTsPluginOptions": {}, to the tsconfig file. Now its able to parse correctly as expected 👍
NOTE: if you have a , on the last line in "compilerOptions" it breaks. Removing this comma, fixes the issue. https://stackoverflow.com/questions/201782/can-you-use-a-trailing-comma-in-a-json-object/201856#201856
Thanks @Vipsey. It's weird that
"parcelTsPluginOptions": {
"transpileOnly": false
}
does not work but
"parcelTsPluginOptions": {}
works.
the needs-repro can be removed, I suppose.