Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

flow + async + default params => Unexpected Token error (T7484) #92

Closed
danez opened this issue Aug 16, 2016 · 0 comments · Fixed by #95 or #96
Closed

flow + async + default params => Unexpected Token error (T7484) #92

danez opened this issue Aug 16, 2016 · 0 comments · Fixed by #95 or #96
Labels

Comments

@danez
Copy link
Member

danez commented Aug 16, 2016

Reported by @spudly

const testFunc = async (arg: string = '') => {};
export default testFunc;

The code above results in an Unexpected Token error.

If you remove 'async' or remove " = ''", it parses successfully.

http://babeljs.io/repl/#?evaluate=false&lineWrap=false&presets=es2015%2Creact%2Cstage-0&experimental=true&loose=true&spec=false&code=%2F%2F%20%40flow%0A%0Aconst%20testFunc%20%3D%20async%20(arg%3A%20string%20%3D%20'')%20%3D%3E%20%7B%7D%3B%0A%0Aexport%20default%20testFunc%3B%0A


Comment by @BLamy

This issue has nothing to do with flow. It's a combination of arrow functions, async-await and destructured default parameters.

const example5 = async function({bar = "bar"}) { // Works fine
    console.log(bar);
}

const example6 = async ({bar = "bar"}) => { // Syntax error
    console.log(bar);
}
@danez danez added the i: bug label Aug 16, 2016
@danez danez changed the title flow + async + default params => Unexpected Token error flow + async + default params => Unexpected Token error (T7484) Aug 16, 2016
@hzoo hzoo closed this as completed in #96 Aug 23, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
1 participant