-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
ES2015 & 2016 Features meta-issue #560
Comments
this is super useful! there are probably a bunch of new APIs that we need to add, too. for example, I just noticed that we don't have |
Perhaps, add an ES7 section and mark async-await as done. (BTW, I find it surprising that async-await is done before generators!) |
It seems there is an issue with ES6 Class support. I am using atom/nuclide IDE and having the following code: export default class Resource {
constructor(req:string) {
this.req = req * 2;
}
}
|
@Globegitter, Flow wants you to declare class properties like so: export default class Resource {
req: number;
constructor(req: number) {
this.req = req * 2;
}
} Why do we require this? Well, if we don't make people declare properties then we can't detect things like function getReq(resource: Resource): number {
return resource.rep;
} We do realize this is a little bit more work for the developer, but we're hoping the benefits outweigh the pain. |
Aahh, I see, thanks @gabelevi For know I mostly want to use flow for its type inference with Generally I do think this is an acceptable extra-effort, but why can flow not just get the information from the constructor itself? Is it that much more complex to see what As a side note kind of fitting to this, it would be great to see property initialiser support as mentioned here: http://babeljs.io/blog/2015/06/07/react-on-es6-plus/ |
I think at the moment that Flow requires type annotations for the class member properties you declare. So req: any; res: any; should work. I did recently change the parsing of that (7e5b2a9) in preparation for class property initializers. We absolutely are planning support for class property initializers. They solve so many problems! The one I hate the most is how you have to do class Foo {
constructor() {
this.myCallBack = this.myCallBack.bind(this);
}
myCallBack() { ... }
} but with class property initializers you can do class Foo {
myCallBack = () => { ... }
} |
Thanks for the quick response that all sounds good :) And yep it really does solve a lot of issues. |
@Globegitter, good insight! Actually, flow used to do this, but the functionality was removed. I'm not sure about the details surrounding this, but there is some explanation in a comment in the source code. Unfortunately, this change was from the days of "sync to upstream" so the diff is big and it's hard to see the implications in terms of the code changes themselves. |
^ What happened with I think it'd help if this was taken care of if only because at a glance it makes the whole project seem to be behind. For example it's being used as a con on this list, which happens to be a top result for googling "flow vs TypeScript"
Also in this comment: Flow looks really promising, keep up the great work! |
We're actively working on it. Please be patient. |
@oztune by all means use my fork in the mean time: github.com/nmn/flow
|
classes are checked, but class property initializers are not supported: can we have a check box for that? Making it hard for me to swallow ES6 classes right now. An alternative approach to much of this work is to leverage babel more |
@gregwebs class property initializers are not ES6/ES2015, but it's definitely on our radar. I think, instead of creating a separate meta issue for ES2016 features, we should just track that here. I'll make the necessary changes. |
Ah, in that case I will take any hack I can get. Seems to work to put this in the constructor: // fix broken es6 classes
_.each(Object.getOwnPropertyNames( Object.getPrototypeOf(this) ), prop => {
this[prop] = this[prop].bind(this)
}) |
@samwgoldman I think it would make sense to update #431 to #784 given that's where the ongoing work is now. |
@Gozala You're right! Thanks & done. |
I'd vote for adding export extensions to the ES2016 list. (Not sure if they're supported?) |
Is there an maintained list of the various proposals, along with the stage? Official would be ideal, but anything would help. |
@samwgoldman there's a list of the ones that are available in babel. |
export default from './some-component'; throws "Unexpected string" error. Issue is resolved via some "hack": export { default } from './some-component'; |
That is not some hack, that is the correct syntax (reexport the "default" export as an export named "default"). |
Thank you. I thought it's already in specification, because webpack 2 understands |
|
|
@samwgoldman I believe this
is already done as of d3887c2. Is this list still maintained? |
Still no support for do-expressions? :C |
Any news about do-expressions? They are extremely useful for FP-style, but I can't use flow together with them. |
Throw expressions: #6605 |
do expressions ftw! |
Came here to say "do expressions ftw!" but I see I already did this in July :-\ heh |
Not seeing flow errors for throw expressions would be incredibly nice! |
still waiting for do expressions |
@SPAHI4 it is not standard |
Updated list in post to reflect latest proposals |
This issue is old and no longer up to date. We can track the remaining features left in individual issues. |
@gkz the top-level await issue is closed :( blah nvm found it ;) |
Feel free to open an issue for any unchecked feature that doesn't already have one, but please try to keep discussion in a single issue if possible. Use cases (and test cases) are very welcome!
To report a bug with a completed feature, please open a new issue for the bug.
ES2015+
this
: Flow error on using this.x as a default param in a class #1234)strings
param has araw
propstrings
andraw
arrays are frozennew.target
(new.target support #1152)typeof x === "symbol"
#1015)export Foo from 'foo'
(Is export something from 'something supported? #2403)String.prototype.matchAll
(Add String.prototype.matchAll #7812)Promise.allSettled
Proposals
Stage 4
String.prototype.replaceAll
Stage 3
BigInt
(BigInt typechecking #7602)globalThis
(Support globalThis proposal #7704)import.meta
(Flow parser should support import.meta #6913)await
(Top-level await #7710)WeakRefs
Stage 2
Promise.any
function.sent
throw
expressions (Support for throw expressions #6605)Atomics.waitAsync
Set
methodsArrayBuffer.prototype.transfer
Temporal
Array.isTemplateObject
Stage 1
do
expressions (Support for Syntax Do Expression #2523)Emitter
Stage 0
The text was updated successfully, but these errors were encountered: