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

Flow annotation is incorrectly removed? #357

Open
kangax opened this issue Dec 22, 2016 · 4 comments
Open

Flow annotation is incorrectly removed? #357

kangax opened this issue Dec 22, 2016 · 4 comments
Labels
bug Confirmed bug

Comments

@kangax
Copy link
Member

kangax commented Dec 22, 2016

require('babel-core').transform('export default function(foo: string, bar: string = baz()) { }', {plugins:['syntax-flow'],passPerPreset:true,presets:['babili']}).code

gives me this:

export default function (a: string, b = baz()) {}

Shouldn't this be:

export default function (a: string, b: string = baz()) {}

/cc @boopathi

@boopathi
Copy link
Member

Interesting that it didn't happen for a - mangler replaces the identifier and will create a new identifier and this one won't have the type information.

Just curious - why would you want a type annotation for minified code - don't we assume the output is JavaScript? If we do some unsafe transformations, types are going to mismatch somewhere and flow is going to throw an error on the transformed code.

@kangax
Copy link
Member Author

kangax commented Dec 25, 2016

I stumbled at this when running a smoke test (on Babel repo, actually). It was erroring out without 'syntax-flow' plugin so once I added that I noticed this inconsistency in output. So this is purely theoretical at this point but still shows that something is off.

@kangax kangax added the bug Confirmed bug label Dec 25, 2016
@boopathi
Copy link
Member

With #390, all bindings should get flow removed, as we were doing previously binding.identifier.name = newName. Now we replace the identifier using path. So flow annotation should be removed.

@kangax
Copy link
Member Author

kangax commented Jan 30, 2017

Hm, I still get export default function (foo: string, bar: string = baz()) {} even on latest master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants