parcel-plugin-typescript icon indicating copy to clipboard operation
parcel-plugin-typescript copied to clipboard

Type-checking errors aren't reported

Open qwertie opened this issue 7 years ago • 12 comments

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"})

qwertie avatar Jun 18 '18 03:06 qwertie

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.

fathyb avatar Jun 18 '18 06:06 fathyb

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?

qwertie avatar Jun 19 '18 12:06 qwertie

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?

fathyb avatar Jun 19 '18 13:06 fathyb

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.

qwertie avatar Jun 20 '18 21:06 qwertie

Awesome, that's perfect, thanks. Will check ASAP.

fathyb avatar Jun 21 '18 04:06 fathyb

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

Sharlaan avatar Jun 21 '18 16:06 Sharlaan

I always get a pass when using this plugin when tsc reports errors

quantuminformation avatar Jul 27 '18 08:07 quantuminformation

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)```

quantuminformation avatar Jul 27 '18 10:07 quantuminformation

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. (.../node_modules/parcel-plugin-typescript/build/backend/config-loader.js:25:37) at Generator.next ()

Vipsey avatar Aug 08 '18 09:08 Vipsey

@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

Vipsey avatar Aug 08 '18 13:08 Vipsey

Thanks @Vipsey. It's weird that

"parcelTsPluginOptions": {
  "transpileOnly": false
}

does not work but

"parcelTsPluginOptions": {}

works.

tan-nhu avatar Aug 23 '18 05:08 tan-nhu

the needs-repro can be removed, I suppose.

muelli avatar Oct 24 '19 08:10 muelli