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

Babel chokes on valid Flow syntax (`typeof blah.default`) #10571

cakoose opened this issue Oct 18, 2019 · 1 comment · May be fixed by #10657


Copy link

@cakoose cakoose commented Oct 18, 2019

Bug Report


    "devDependencies": {
        "@babel/cli": "7.6.4",
        "@babel/core": "7.6.4",
        "@babel/preset-flow": "7.0.0",
        "flow-bin": "0.109.0"




    "presets": ["@babel/preset-flow"]


// @flow
type Stuff = {
  x: number,
  default: string,

function f(stuff: Stuff) {
  const x: typeof stuff.x = 1;
  const y: typeof stuff.default = "hi";

Flow runs fine:

$ ./node_modules/.bin/flow 
No errors!

Babel does not:

$ ./node_modules/.bin/babel src
{ SyntaxError: /Users/kannan/h/babel-flow-default-token/src/test.js: Unexpected keyword 'default' (9:24)

   7 | function f(stuff: Stuff) {
   8 |   const x: typeof stuff.x = 1;
>  9 |   const y: typeof stuff.default = "hi";
     |                         ^
  10 | }
  11 | 
    at Object.raise (/Users/kannan/h/babel-flow-default-token/node_modules/@babel/parser/lib/index.js:6420:17)
    at Object.checkReservedWord (/Users/kannan/h/babel-flow-default-token/node_modules/@babel/parser/lib/index.js:9722:12)
    at Object.parseIdentifierName (/Users/kannan/h/babel-flow-default-token/node_modules/@babel/parser/lib/index.js:9697:12)
    at Object.parseIdentifier (/Users/kannan/h/babel-flow-default-token/node_modules/@babel/parser/lib/index.js:9667:23)
    at Object.flowParseQualifiedTypeIdentifier (/Users/kannan/h/babel-flow-default-token/node_modules/@babel/parser/lib/index.js:1595:23)
    at Object.flowParseGenericType (/Users/kannan/h/babel-flow-default-token/node_modules/@babel/parser/lib/index.js:1605:20)
    at Object.flowIdentToTypeAnnotation (/Users/kannan/h/babel-flow-default-token/node_modules/@babel/parser/lib/index.js:1713:21)
    at Object.flowParsePrimaryType (/Users/kannan/h/babel-flow-default-token/node_modules/@babel/parser/lib/index.js:1732:21)
    at Object.flowParseTypeofType (/Users/kannan/h/babel-flow-default-token/node_modules/@babel/parser/lib/index.js:1617:26)
    at Object.flowParsePrimaryType (/Users/kannan/h/babel-flow-default-token/node_modules/@babel/parser/lib/index.js:1862:23)
  pos: 142,
  loc: Position { line: 9, column: 24 },

My Node version:

$ node --version

BTW, I know Flow is processing the file because I added a type error to "test.js" and Flow caught it.


This comment has been minimized.

Copy link

@babel-bot babel-bot commented Oct 18, 2019

Hey @cakoose! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@babel babel deleted a comment from meandmax Oct 21, 2019
@existentialism existentialism self-assigned this Nov 5, 2019
@existentialism existentialism referenced a pull request that will close this issue Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.