Implement support for declare on class fields with Flow#11178
Implement support for declare on class fields with Flow#11178nicolo-ribaudo merged 6 commits intobabel:masterfrom
declare on class fields with Flow#11178Conversation
fa59688 to
195b16a
Compare
packages/babel-parser/test/fixtures/flow/class-properties/declare-static-field/input.js
Show resolved
Hide resolved
| @@ -0,0 +1,3 @@ | |||
| class A { | |||
| declare [foo] | |||
| } | |||
There was a problem hiding this comment.
Flow does not support declared computed class fields yet: https://flow.org/try/#0G4QwTgBAZg9jEF4IEYDcAoAxgGxAZzwgEEIBvdCCAEwFMdwaIBtWGAXXQF8g
There was a problem hiding this comment.
It's not released yet.
Looking at the source code it doesn't seem to be disallowed (facebook/flow@11b7adb#diff-ca4a151bb3ce5bd8c11f1bc3b00036ebR619), but I don't see any test to confirm my assumption.
cc @@mroch should they be supported?
There was a problem hiding this comment.
change the version selector in the top right to master and it parses.
It does error with "Computed property keys not supported.", but that's a type error, not a parse error (you can tell the difference on the CLI, but on Try Flow it's only in the JSON tab ("kind": "infer"))
a7d4f32 to
9a0bc5b
Compare
|
I split the error into two different errors to match Flow (https://github.com/facebook/flow/blob/cb99c11e0f620a981b6cea5c5ba2f02c7263679b/src/parser/parse_error.ml#L325-L326). |
|
@nicolo-ribaudo Can you also update https://babeljs.io/docs/en/babel-preset-flow#options? |
Flow has recently landed support for
declarefields, similar to TypeScript. (facebook/flow@11b7adb)This PR implements parser support, and adds an
allowDeclareFieldsoption to the transform plugin to mirror the one of@babel/plugin-transform-typescript. In Babel 8 it will be enabled by default.Even if it's not released yet in Flow, I'm adding this to the v7.9.0 milestone since Flow is released about once a week.
cc @mroch