Skip to content

decorators on generator functions parse error with --typescript #6680

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

Open
wangtao0101 opened this issue Mar 19, 2019 · 2 comments
Open

decorators on generator functions parse error with --typescript #6680

wangtao0101 opened this issue Mar 19, 2019 · 2 comments

Comments

@wangtao0101
Copy link

Is this a bug report?

(write your answer here)
Yes

Did you try recovering your dependencies?

(Write your answer here.)
npm --version
6.4.1

Which terms did you search for in User Guide?

(Write your answer here if relevant.)
decorators on generator functions parse error with --typescript

Environment

(paste the output of the command here)

Environment Info:

System:
OS: Windows 10
CPU: x64 Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz
Binaries:
Yarn: 1.10.1 - C:\Program Files\nodejs\yarn.CMD
npm: 6.1.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 42.17134.1.0
Internet Explorer: 11.0.17134.1
npmPackages:
react: ^16.8.4 => 16.8.4
react-dom: ^16.8.4 => 16.8.4
react-scripts: Not Found
npmGlobalPackages:
create-react-app: Not Found

Steps to Reproduce

(Write your steps here:)

  1. create-react-app my-app typescript
  2. add experimentalDecorators in tsconfig.json
  3. add related code
@effect() // define async action handle
    * addAsync(count: number) {
        yield delay(2000);
        this.add(count); // type check here
    }

Expected Behavior

(Write what you thought would happen.)

parse success

Actual Behavior

(Write what happened. Please add screenshots!)

./src/AppModel.ts
SyntaxError: C:\Users\zeroone\Desktop\my-app\src\AppModel.ts: Unexpected token (17:30)

  15 | export default class AppModel extends Model<AppState> {
  16 |     @effect() // define async action handle
> 17 |     * addAsync(count: number) {
     |                               ^
  18 |         yield delay(2000);
  19 |         this.add(count); // type check here
  20 |     }

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

@mrmckeb
Copy link
Contributor

mrmckeb commented Mar 25, 2019

Hi @wangtao0101, I believe this is related to #6225.

If so, it looks like this was just solved on the Babel side and we'll be able to fix this by bumping our dependencies. babel/babel#9693

Would you like to submit a PR for that?

@wangtao0101
Copy link
Author

@mrmckeb after i try @babel/[email protected], the bug was still, but i agree that maybe the bug do caused by babel

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

3 participants