parcel-plugin-typescript: Unexpected Token Error

Trying it with a simple Parcel setup, I get unexpected token error for TypeScript;

🚨  /home/azer/code/mobile/src/index.tsx:21:2: Unexpected token, expected "," (21:2)
  19 | ReactDOM.render(<Container>hey, there</Container>, document.getElementById(
  20 |   "root"
> 21 | ) as HTMLElement)
     |  ^

If I remove as HTMLElement from the line above, this time it’ll complain other TypeScript syntax.

Versions I tried:

Parcel: 1.10.1 TypeScript: 3.1.0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 20
  • Comments: 17

Most upvoted comments

@d30jeff The problem is, as soon as I install parcel-plugin-typescript, Parcel treats TS files as JS, and fails with syntax errors.

Any updates on this?

Same issue. Typescript syntax not recognized.

Having the same problem. Installed the plugin to get baseUrl and paths options in tsconfig to work properly.

people should be advised against this plugin, my project started failing building with no apparent reason. this plugin was added to the “devDependencies” and broke everything. looked like it was a problem with Parcel itself, or a babel misconfiguration, but I managed to pin down the problem since this warning appeared:

npm WARN parcel-plugin-typescript@1.0.0 requires a peer of typescript@^2.4.0 but none is installed. You must install peer dependencies yourself.

that’s how I figured out it was the culprit

work around install in dev dependncies “parcel-bundler”: “1.9.4”, it works with this out of date version of parcel

any update ?