Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type-checking errors aren't reported #43

Open
qwertie opened this issue Jun 18, 2018 · 12 comments
Open

Type-checking errors aren't reported #43

qwertie opened this issue Jun 18, 2018 · 12 comments

Comments

@qwertie
Copy link

qwertie commented Jun 18, 2018

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"})
@fathyb
Copy link
Owner

fathyb commented Jun 18, 2018

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.

@qwertie
Copy link
Author

qwertie commented Jun 19, 2018

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?

@fathyb
Copy link
Owner

fathyb commented Jun 19, 2018

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 fathyb changed the title Why doesn't it work? Type-checking error aren't reported Jun 19, 2018
@fathyb fathyb changed the title Type-checking error aren't reported Type-checking errors aren't reported Jun 19, 2018
@qwertie
Copy link
Author

qwertie commented Jun 20, 2018

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.

@fathyb
Copy link
Owner

fathyb commented Jun 21, 2018

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

@Sharlaan
Copy link

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

@quantuminformation
Copy link

quantuminformation commented Jul 27, 2018

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

@quantuminformation
Copy link

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

@Vipsey
Copy link

Vipsey commented Aug 8, 2018

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
Copy link

Vipsey commented Aug 8, 2018

@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

@tan-nhu
Copy link

tan-nhu commented Aug 23, 2018

Thanks @Vipsey. It's weird that

"parcelTsPluginOptions": {
  "transpileOnly": false
}

does not work but

"parcelTsPluginOptions": {}

works.

@muelli
Copy link

muelli commented Oct 24, 2019

the needs-repro can be removed, I suppose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants