hermes-parser 0.31.2 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +3 -0
  2. package/dist/HermesASTAdapter.js +2 -2
  3. package/dist/HermesASTAdapter.js.flow +2 -2
  4. package/dist/HermesParserDeserializer.js +0 -1
  5. package/dist/HermesParserDeserializer.js.flow +0 -1
  6. package/dist/HermesParserWASM.js +1 -1
  7. package/dist/ParserOptions.js +1 -1
  8. package/dist/ParserOptions.js.flow +8 -0
  9. package/dist/babel/TransformESTreeToBabel.js +11 -8
  10. package/dist/babel/TransformESTreeToBabel.js.flow +11 -8
  11. package/dist/estree/{StripComponentSyntax.js → TransformComponentSyntax.js} +2 -2
  12. package/dist/estree/{StripComponentSyntax.js.flow → TransformComponentSyntax.js.flow} +2 -2
  13. package/dist/estree/TransformEnumSyntax.js +106 -0
  14. package/dist/estree/TransformEnumSyntax.js.flow +125 -0
  15. package/dist/index.js +6 -3
  16. package/dist/index.js.flow +6 -3
  17. package/dist/src/HermesASTAdapter.js +2 -2
  18. package/dist/src/HermesParserDeserializer.js +0 -1
  19. package/dist/src/ParserOptions.js +1 -1
  20. package/dist/src/babel/TransformESTreeToBabel.js +11 -8
  21. package/dist/src/estree/{StripComponentSyntax.js → TransformComponentSyntax.js} +2 -2
  22. package/dist/src/estree/TransformEnumSyntax.js +106 -0
  23. package/dist/src/index.js +6 -3
  24. package/dist/src/transform/SimpleTransform.js +20 -4
  25. package/dist/src/transform/astNodeMutationHelpers.js +7 -2
  26. package/dist/transform/SimpleTransform.js +20 -4
  27. package/dist/transform/SimpleTransform.js.flow +34 -8
  28. package/dist/transform/astNodeMutationHelpers.js +7 -2
  29. package/dist/transform/astNodeMutationHelpers.js.flow +10 -2
  30. package/package.json +2 -2
package/README.md CHANGED
@@ -9,3 +9,6 @@ The Hermes parser exposes a single `parse(code, [options])` function, where `cod
9
9
  - **sourceFilename**: `string`, defaults to `null`. The filename corresponding to the code that is to be parsed. If non-null, the filename will be added to all source locations in the output AST.
10
10
  - **sourceType**: `"module"`, `"script"`, or `"unambiguous"` (default). If `"unambiguous"`, source type will be automatically detected and set to `"module"` if any ES6 imports or exports are present in the code, otherwise source type will be set to `"script"`.
11
11
  - **tokens**: `boolean`, defaults to `false`. If `true`, add all tokens to a `tokens` property on the root node.
12
+ - **transformOptions**: `object`. Options to be supplied to relevant transforms.
13
+ - `TransformEnumSyntax`
14
+ - `getRuntime` (optional): `() => Expression` - The expression which should be a reference to the Flow Enums runtime. By default, is `require('flow-enums-runtime')`.
@@ -59,7 +59,7 @@ class HermesASTAdapter {
59
59
 
60
60
  if (resultNode.type !== 'Program') {
61
61
  throw new Error(`HermesToESTreeAdapter: Must return a Program node, instead of "${resultNode.type}". `);
62
- } // $FlowExpectedError[incompatible-return] We know this is a program at this point.
62
+ } // $FlowExpectedError[incompatible-type] We know this is a program at this point.
63
63
 
64
64
 
65
65
  return resultNode;
@@ -130,7 +130,7 @@ class HermesASTAdapter {
130
130
  }
131
131
 
132
132
  mapEmpty(_node) {
133
- // $FlowExpectedError
133
+ // $FlowExpectedError[incompatible-type]
134
134
  return null;
135
135
  }
136
136
 
@@ -65,7 +65,7 @@ export default class HermesASTAdapter {
65
65
  );
66
66
  }
67
67
 
68
- // $FlowExpectedError[incompatible-return] We know this is a program at this point.
68
+ // $FlowExpectedError[incompatible-type] We know this is a program at this point.
69
69
  return resultNode;
70
70
  }
71
71
 
@@ -125,7 +125,7 @@ export default class HermesASTAdapter {
125
125
  }
126
126
 
127
127
  mapEmpty(_node: HermesNode): HermesNode {
128
- // $FlowExpectedError
128
+ // $FlowExpectedError[incompatible-type]
129
129
  return null;
130
130
  }
131
131
 
@@ -201,7 +201,6 @@ class HermesParserDeserializer {
201
201
 
202
202
 
203
203
  addEmptyLoc() {
204
- // $FlowExpectedError
205
204
  const loc = {};
206
205
  this.locMap[this.next()] = loc;
207
206
  return loc;
@@ -223,7 +223,6 @@ export default class HermesParserDeserializer {
223
223
  * objects that are filled after the AST has been deserialized.
224
224
  */
225
225
  addEmptyLoc(): HermesSourceLocation {
226
- // $FlowExpectedError
227
226
  const loc: HermesSourceLocation = {};
228
227
  this.locMap[this.next()] = loc;
229
228
  return loc;