Unexpected token `@` when using decorators
See original GitHub issueWhat version of Next.js are you using?
12.0.2
What version of Node.js are you using?
v14.18.1
What browser are you using?
Brave
What operating system are you using?
macOS
How are you deploying your application?
Vercel
Describe the Bug
Error when using decorators in next@12.0.2:
./pages/index.tsx
Error: error: Unexpected token `@`. Expected identifier, string literal, numeric literal or [ for the computed key
|
10 | @Decorator()
| ^
Caused by:
0: failed to process js file
1: Syntax Error
Expected Behavior
Decorators to work.
To Reproduce
- Run
npm run build
in this sandbox
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Property decorators throw "Parsing error: Unexpected token"
I'm using Angular2+ES6 which requires both @Class and @Property decorators. With the parser set to 'babel-eslint' the class decorators aren't throwing any ...
Read more >[Solved]-Jest: Unexpected token @ Decorator-Reactjs
I think you'll need to add a .babelrc file. It sounds like you're missing the es2016 plugin for babel, which converts ES7 code...
Read more >swc with node, typescript & decorators fails at "error - Reddit
swc with node, typescript & decorators fails at "error: Unexpected token Some(At)". Code looks like this: const fs = require('fs-extra'); ...
Read more >Enabling decorators · MobX
Decorator syntax and Create React App (v2) ... Decorators are only supported out of the box when using TypeScript in create-react-app@^2.1.1 and newer....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@virus231 @lbozzo it is fixed in the stable release as well!
@virus231 It seems that as of this moment, it is fixed in Canary.
yarn add next@canary