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

Support for ES6 features #62

Closed
jlongster opened this issue Nov 19, 2014 · 55 comments
Closed

Support for ES6 features #62

jlongster opened this issue Nov 19, 2014 · 55 comments

Comments

@jlongster
Copy link

I didn't see an existing issue for this, nor do I see anything on the website about it, but I'm sure you all have plans for this. Looks like there are several ES6 features this doesn't support yet, particularly let:

let x = 5;
/Users/james/projects/mozilla/gecko-dev/toolkit/devtools/server/actors/foo.js:3:1,10: 
Unsupported variable declaration: let

/Users/james/projects/mozilla/gecko-dev/toolkit/devtools/server/actors/foo.js:3:5,5: var x
Unknown global name

I'm interested in using this as a "light" type checker in Firefox. I don't know if we'll ever start adding a lot of type declarations, but this looks like it could be a nice "linter" using the weak mode. (still not sure how far that goes yet, but if it can even catch a few things that would be cool).

Since we can code against SpiderMonkey, we use ES6 a lot, like:

  • let/const
  • for-of
  • short-hand object syntax ({ foo } turns into { foo: foo })
  • generators

That's just off the top of my head. On the file I tried, the main things I hit were let/const and for-of.

@vjeux
Copy link
Contributor

vjeux commented Nov 19, 2014

short-hand object syntax ({ foo } turns into { foo: foo })

This one is supported :)

/* @flow */
var a = 'a';
var b = {a};
$> flow check
No errors!

@briandipalma
Copy link

Not only that but when I tried to run it on my ES6 repos flow seemed to go into an infinite loop.
I killed it after 15 mins or so but it provided no feedback, I tried shorter runs with --profile and that wasn't so helpful. I guess flow has an npm package resolver that allows it to follow CJS requires, correct?

Add modules to the ES6 list.

/home/brian/dev/global-compiler/src/cjs-require-remover.js: 
Failure("Unimplemented: ExportDeclaration")

@avikchaudhuri
Copy link
Contributor

ES6 compatibility is an explicit goal. We'll fix let and for-of right away, generators may be a bit longer (but soon).

@avikchaudhuri
Copy link
Contributor

@briandipalma Hmm, if Flow goes into an infinite loop that's a bug, so providing more information would be helpful (like if you could narrow down to one file that's causing it). We'll put more logging information in the binary to make it useful to do this kind of debugging.

On the other hand, it may be that there's a particularly large file or a file with a lot of reflection in your repo and that's causing Flow's type inference to be ridiculously confused. Again, would be good to know which file.

@tcoopman
Copy link
Contributor

@avikchaudhuri is support for const also planned?

@avikchaudhuri
Copy link
Contributor

Sure, we can add that too.

@tcoopman
Copy link
Contributor

@avikchaudhuri I should have been more clear, but I was also wondering if flow will enforce the const so that this will be an error:

const x = 5;
x = 6; // Error cannot reassign const

@avikchaudhuri
Copy link
Contributor

Sure, otherwise what's the point? :)

@tcoopman
Copy link
Contributor

Fantastic :)

On Thu Nov 20 2014 at 10:51:35 AM Avik Chaudhuri [email protected]
wrote:

Sure, otherwise what's the point? :)


Reply to this email directly or view it on GitHub
#62 (comment).

@jlongster
Copy link
Author

fwiw, my vote priority-wise is generators and then let/const. Generators are the biggest thing holding me back from using it. I know it'll get there though!

@gothy
Copy link

gothy commented Nov 22, 2014

async\await would be nice also :)

@koorchik
Copy link

It would be nice to have destructive assignment support too.

function test({prop = 'defaultValue'}) { }

will error

Unexpected token =

@OliverJAsh
Copy link

I'm using a lot of ES6 features via Traceur. I mainly need flow to support modules (import/export) and arrow functions.

@josebalius
Copy link

+1 for modules

@RobertoUa
Copy link

👍
Please do it :)

@solidsnack
Copy link

+1 for import

@peterwmwong
Copy link

+1 for modules

@tenorok
Copy link

tenorok commented Jan 15, 2015

+1 for let and const

@vanwagonet
Copy link
Contributor

+1 for async/await. Would love to use flow with 6to5.

@junosuarez
Copy link

+1 for only supporting things that are directly relevant to type checking. Many of the new ES6 keywords have no effect on checking / inference.

@iammerrick
Copy link

Modules please... :-)

@nemoo
Copy link

nemoo commented Feb 28, 2015

+1 for arrow functions

@mrmurphy
Copy link

mrmurphy commented Mar 4, 2015

Are +1's helpful? The things that I'm really hoping for are import/export, const/let, and generators.


Edit: It looks like generators are happy now I think. Thanks!

@ivanoats
Copy link

ivanoats commented Mar 4, 2015

Something that would be helpful here would be a checklist like in eslint/js#10 so that we can see how close we are.

@mrmurphy
Copy link

mrmurphy commented Mar 6, 2015

Also, :sadtrombone:, I had just tested:

var foo = function *() {
  foooooooo()
}

And I didn't get any errors. I hand't tried actually putting in a yield statement yet. Sorry. Generators are still unsupported.

@johanneslumpe
Copy link

Is there any update on this? The support for es6 modules would be really something to look forward to. Currently a show stopper for me as the whole project here is purely written in es6 using babel

@danvk
Copy link
Contributor

danvk commented Mar 18, 2015

Could we add getter/setter methods to the list?

class MyList<T> {
  list: T[];
  constructor(list: T[]) { this.list = list; }
  get length() { return this.list.length; }
}
new MyList([1,2,3]).length

@ccapndave
Copy link

+1 modules!

@ghost
Copy link

ghost commented Mar 20, 2015

👍 for the modules, is it in the roadmap for the near future?

@dead-claudia
Copy link

@callumlocke
Copy link
Contributor

What @ivanoats said. Can a collaborator please edit the issue description at the top to add a GFM checklist like this, and check things off as they are done?

I keep coming back to this thread to find out if Flow is compatible with my project yet, and a checklist would really help me out!

@OliverJAsh
Copy link

+1 for a checklist

@dead-claudia
Copy link

Checklist would be awesome. +1

@milesj
Copy link
Contributor

milesj commented May 13, 2015

Is there a status page on what ES6 features are currently supported? Would be nice to have a quick overview. I keep running into blockers when implementing flow in my ES6 projects.

Edit: Should of read the previous comments. A checklist would be great. 👍

@seanhess
Copy link

+1 for generators. Thank you so much for implementing modules!

@friday
Copy link

friday commented May 20, 2015

+1 for stop using this issue thread as a poll of specific unimplemented es6-features, however +1 for a checklist!

wincent added a commit to wincent/corpus that referenced this issue May 29, 2015
- adds a gulp task (not baked into "watch" yet because Flow is pretty
  broken right now with respect to a lot of ES6 features[*])
- updates license headers to include `@flow` pragma (I wanted to use
  `gulp-flowtype`'s `all` option, but that doesn't seem to work; Flow
  seems to want to scan everything in `node_modules`, even though gulp
  is set to watch only files under `src/`)

So, very much a work in progress. It might be useful eventually.

[*]: See facebook/flow#62; the version of Flow
currently on Homebrew (0.11.0) doesn't support `const`, which I use all
over the place, as well as a number of other features.
@jgod
Copy link

jgod commented Jun 12, 2015

+1. looking forward to let/const support

@ccapndave
Copy link

Note that you can get most ES6 feature in Flow right now by running your code through Babel with the flow blacklist. http://www.keendevelopment.ch/flow-babel-gulp-es6/ has a recipe for doing this.

@leeola
Copy link

leeola commented Jun 17, 2015

@ccapndave The problem with that, at least in my case, is that Flow can have problems with the generated code from Babel. Eg, for me even using class with a method, eg:

class MyClass {
  func() {}
}

will cause babel to generate code that Flow believes is incorrect. Specifically the _createClass generated line. Have you found a workaround for that? (and possible other generated code issues)

@frankychung
Copy link

@leeola in that case blacklisting es6.classes will solve that issue since Flow understands ES6 classes.

@seanhess
Copy link

@ccapndave wouldn't that make all your flow errors report incorrect line numbers?

@ccapndave
Copy link

I don't use classes in ES6 so I couldn't say for sure, but I think the sourcemaps will figure it all out. Have a go and let us know!

@samwgoldman
Copy link
Member

Thanks for your input, everyone! I'm organizing the existing issues around this and taking @callumlocke's advice to create a checklist. To that end, I'm merging this with #560.

@rope-hmg
Copy link

I'm not normally one to complain, but as of flow 0.13.1 I'm still waiting for const/let. I would really love to use flow, but I have a lot of let and const in my project.

Thanks.

@friday
Copy link

friday commented Jul 27, 2015

@Hector409-hmg Work is being done (or at least was until recently). They're implementing it the "proper" way. If you just want to be able to use let/const, but have flow validate them as var there are instructions in the "Let/const" pr comments: #431 (comment)

@oguzbilgic
Copy link

+1 for let const

@vjpr
Copy link

vjpr commented Jul 28, 2015

+1

jeffmo added a commit to jeffmo/flow that referenced this issue Jul 31, 2015
Parse object type indexer properties
@webhipster
Copy link

+1

@meagar
Copy link

meagar commented Sep 3, 2015

+1 for let

@dead-claudia
Copy link

@webhipster @meagar and anyone else here, please check out #560.

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