1
votes

I have this code:

var loadTempImpersonationToken = (username: string): Promise => client({
  uri: `endpoint`,
  cache: false
})

As you can see, this includes both an arrow function, and flow type annotations. Babel supports arrow functions (in the es2015 & stage-0 presets) as well as stripping type annotations, in the react preset.

Simply combining the presets fails:

{"presets": [
    "stage-0",
    "react"
]}

Produces

Error: Parse Error: Line 1: Unexpected token : while parsing file: /Users/tmcw/src/example.js

How does one support these features in the same code?

1
That compiles fine with those presets enabled, are you sure you have configured Babel properly? - loganfsmyth

1 Answers

1
votes

Turns out I had misconfigured babel - it was reading a different .babelrc file than the one I had set up. Sorry for the noise!