GithubHelp home page GithubHelp logo

Support for ES6 features about flow HOT 55 CLOSED

facebook avatar facebook commented on April 19, 2024
Support for ES6 features

from flow.

Comments (55)

dead-claudia avatar dead-claudia commented on April 19, 2024 2

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

from flow.

danvk avatar danvk commented on April 19, 2024 1

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

from flow.

vjeux avatar vjeux commented on April 19, 2024

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

This one is supported :)

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

from flow.

briandipalma avatar briandipalma commented on April 19, 2024

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")

from flow.

avikchaudhuri avatar avikchaudhuri commented on April 19, 2024

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

from flow.

avikchaudhuri avatar avikchaudhuri commented on April 19, 2024

@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.

from flow.

tcoopman avatar tcoopman commented on April 19, 2024

@avikchaudhuri is support for const also planned?

from flow.

avikchaudhuri avatar avikchaudhuri commented on April 19, 2024

Sure, we can add that too.

from flow.

tcoopman avatar tcoopman commented on April 19, 2024

@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

from flow.

avikchaudhuri avatar avikchaudhuri commented on April 19, 2024

Sure, otherwise what's the point? :)

from flow.

tcoopman avatar tcoopman commented on April 19, 2024

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).

from flow.

jlongster avatar jlongster commented on April 19, 2024

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!

from flow.

gothy avatar gothy commented on April 19, 2024

async\await would be nice also :)

from flow.

koorchik avatar koorchik commented on April 19, 2024

It would be nice to have destructive assignment support too.

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

will error

Unexpected token =

from flow.

OliverJAsh avatar OliverJAsh commented on April 19, 2024

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

from flow.

josebalius avatar josebalius commented on April 19, 2024

+1 for modules

from flow.

RobertoUa avatar RobertoUa commented on April 19, 2024

👍
Please do it :)

from flow.

solidsnack avatar solidsnack commented on April 19, 2024

+1 for import

from flow.

peterwmwong avatar peterwmwong commented on April 19, 2024

+1 for modules

from flow.

tenorok avatar tenorok commented on April 19, 2024

+1 for let and const

from flow.

vanwagonet avatar vanwagonet commented on April 19, 2024

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

from flow.

junosuarez avatar junosuarez commented on April 19, 2024

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

from flow.

iammerrick avatar iammerrick commented on April 19, 2024

Modules please... :-)

from flow.

nemoo avatar nemoo commented on April 19, 2024

+1 for arrow functions

from flow.

mrmurphy avatar mrmurphy commented on April 19, 2024

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!

from flow.

ivanoats avatar ivanoats commented on April 19, 2024

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

from flow.

mrmurphy avatar mrmurphy commented on April 19, 2024

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.

from flow.

johanneslumpe avatar johanneslumpe commented on April 19, 2024

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

from flow.

zerkalica avatar zerkalica commented on April 19, 2024

+1 Yes, let, const and modules. Babel+flow is a real alternative of typescript.

from flow.

Aetet avatar Aetet commented on April 19, 2024

+1 for using es6 with flow.

from flow.

dead-claudia avatar dead-claudia commented on April 19, 2024

Modules would be very nice. +1

from flow.

gavriguy avatar gavriguy commented on April 19, 2024

+1 modules

from flow.

 avatar commented on April 19, 2024

+1 modules

from flow.

ccapndave avatar ccapndave commented on April 19, 2024

+1 modules!

from flow.

 avatar commented on April 19, 2024

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

from flow.

dead-claudia avatar dead-claudia commented on April 19, 2024

@dialelo As far as I can tell, yes.

from flow.

callumlocke avatar callumlocke commented on April 19, 2024

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!

from flow.

OliverJAsh avatar OliverJAsh commented on April 19, 2024

+1 for a checklist

from flow.

dead-claudia avatar dead-claudia commented on April 19, 2024

Checklist would be awesome. +1

from flow.

milesj avatar milesj commented on April 19, 2024

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. 👍

from flow.

seanhess avatar seanhess commented on April 19, 2024

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

from flow.

friday avatar friday commented on April 19, 2024

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

from flow.

jgod avatar jgod commented on April 19, 2024

+1. looking forward to let/const support

from flow.

ccapndave avatar ccapndave commented on April 19, 2024

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.

from flow.

leeola avatar leeola commented on April 19, 2024

@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)

from flow.

frankychung avatar frankychung commented on April 19, 2024

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

from flow.

seanhess avatar seanhess commented on April 19, 2024

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

from flow.

ccapndave avatar ccapndave commented on April 19, 2024

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!

from flow.

samwgoldman avatar samwgoldman commented on April 19, 2024

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.

from flow.

rope-hmg avatar rope-hmg commented on April 19, 2024

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.

from flow.

friday avatar friday commented on April 19, 2024

@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)

from flow.

oguzbilgic avatar oguzbilgic commented on April 19, 2024

+1 for let const

from flow.

vjpr avatar vjpr commented on April 19, 2024

+1

from flow.

webhipster avatar webhipster commented on April 19, 2024

+1

from flow.

meagar avatar meagar commented on April 19, 2024

+1 for let

from flow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.