hermes-transform 0.31.2 → 0.32.0

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 (37) hide show
  1. package/dist/generated/special-case-node-types/Comment.js +2 -2
  2. package/dist/generated/special-case-node-types/Comment.js.flow +2 -2
  3. package/dist/generated/special-case-node-types/DeclareExportDeclaration.js +3 -3
  4. package/dist/generated/special-case-node-types/DeclareExportDeclaration.js.flow +3 -3
  5. package/dist/generated/special-case-node-types/ExportNamedDeclaration.js +2 -2
  6. package/dist/generated/special-case-node-types/ExportNamedDeclaration.js.flow +2 -2
  7. package/dist/generated/special-case-node-types/ObjectTypeProperty.js +1 -1
  8. package/dist/generated/special-case-node-types/ObjectTypeProperty.js.flow +1 -1
  9. package/dist/generated/special-case-node-types/misc.js +10 -10
  10. package/dist/generated/special-case-node-types/misc.js.flow +10 -10
  11. package/dist/src/generated/special-case-node-types/Comment.js +2 -2
  12. package/dist/src/generated/special-case-node-types/DeclareExportDeclaration.js +3 -3
  13. package/dist/src/generated/special-case-node-types/ExportNamedDeclaration.js +2 -2
  14. package/dist/src/generated/special-case-node-types/ObjectTypeProperty.js +1 -1
  15. package/dist/src/generated/special-case-node-types/misc.js +10 -10
  16. package/dist/src/transform/TransformContext.js +1 -1
  17. package/dist/src/transform/comments/comments.js +2 -2
  18. package/dist/src/transform/mutations/InsertStatement.js +1 -1
  19. package/dist/src/transform/mutations/ReplaceStatementWithMany.js +1 -1
  20. package/dist/src/transform/mutations/utils/isValidModuleDeclarationParent.js +1 -1
  21. package/dist/src/transform/print.js +21 -6
  22. package/dist/src/traverse/NodeEventGenerator.js +1 -1
  23. package/dist/transform/TransformContext.js +1 -1
  24. package/dist/transform/TransformContext.js.flow +1 -1
  25. package/dist/transform/comments/comments.js +2 -2
  26. package/dist/transform/comments/comments.js.flow +2 -2
  27. package/dist/transform/mutations/InsertStatement.js +1 -1
  28. package/dist/transform/mutations/InsertStatement.js.flow +1 -1
  29. package/dist/transform/mutations/ReplaceStatementWithMany.js +1 -1
  30. package/dist/transform/mutations/ReplaceStatementWithMany.js.flow +1 -1
  31. package/dist/transform/mutations/utils/isValidModuleDeclarationParent.js +1 -1
  32. package/dist/transform/mutations/utils/isValidModuleDeclarationParent.js.flow +1 -1
  33. package/dist/transform/print.js +21 -6
  34. package/dist/transform/print.js.flow +19 -5
  35. package/dist/traverse/NodeEventGenerator.js +1 -1
  36. package/dist/traverse/NodeEventGenerator.js.flow +1 -1
  37. package/package.json +11 -5
@@ -19,7 +19,7 @@ var _detachedNode = require("../../detachedNode");
19
19
  */
20
20
  function LineComment(props) {
21
21
  // $FlowExpectedError[prop-missing]
22
- // $FlowExpectedError[incompatible-return]
22
+ // $FlowExpectedError[incompatible-type]
23
23
  return (0, _detachedNode.detachedProps)(undefined, {
24
24
  type: 'Line',
25
25
  value: props.value
@@ -28,7 +28,7 @@ function LineComment(props) {
28
28
 
29
29
  function BlockComment(props) {
30
30
  // $FlowExpectedError[prop-missing]
31
- // $FlowExpectedError[incompatible-return]
31
+ // $FlowExpectedError[incompatible-type]
32
32
  return (0, _detachedNode.detachedProps)(undefined, {
33
33
  type: 'Block',
34
34
  value: props.value
@@ -18,7 +18,7 @@ import {detachedProps} from '../../detachedNode';
18
18
  export type LineCommentProps = {+value: string};
19
19
  export function LineComment(props: LineCommentProps): LineCommentType {
20
20
  // $FlowExpectedError[prop-missing]
21
- // $FlowExpectedError[incompatible-return]
21
+ // $FlowExpectedError[incompatible-type]
22
22
  return detachedProps<LineCommentType>(undefined, {
23
23
  type: 'Line',
24
24
  value: props.value,
@@ -28,7 +28,7 @@ export function LineComment(props: LineCommentProps): LineCommentType {
28
28
  export type BlockCommentProps = {+value: string};
29
29
  export function BlockComment(props: BlockCommentProps): BlockCommentType {
30
30
  // $FlowExpectedError[prop-missing]
31
- // $FlowExpectedError[incompatible-return]
31
+ // $FlowExpectedError[incompatible-type]
32
32
  return detachedProps<BlockCommentType>(undefined, {
33
33
  type: 'Block',
34
34
  value: props.value,
@@ -21,7 +21,7 @@ var _detachedNode = require("../../detachedNode");
21
21
  function DeclareExportDefaultDeclaration(props) {
22
22
  const node = (0, _detachedNode.detachedProps)(props.parent, {
23
23
  type: 'DeclareExportDeclaration',
24
- // $FlowFixMe[incompatible-call]
24
+ // $FlowFixMe[incompatible-type]
25
25
  declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
26
26
  specifiers: [],
27
27
  source: null,
@@ -34,7 +34,7 @@ function DeclareExportDefaultDeclaration(props) {
34
34
  function DeclareExportDeclarationNamedWithDeclaration(props) {
35
35
  const node = (0, _detachedNode.detachedProps)(props.parent, {
36
36
  type: 'DeclareExportDeclaration',
37
- // $FlowFixMe[incompatible-call]
37
+ // $FlowFixMe[incompatible-type]
38
38
  declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
39
39
  specifiers: [],
40
40
  source: null,
@@ -49,7 +49,7 @@ function DeclareExportDeclarationNamedWithSpecifiers(props) {
49
49
  type: 'DeclareExportDeclaration',
50
50
  declaration: null,
51
51
  specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNode)(n)),
52
- // $FlowFixMe[incompatible-call]
52
+ // $FlowFixMe[incompatible-type]
53
53
  source: (0, _detachedNode.asDetachedNode)(props.source),
54
54
  default: false
55
55
  });
@@ -35,7 +35,7 @@ export function DeclareExportDefaultDeclaration(props: {
35
35
  props.parent,
36
36
  {
37
37
  type: 'DeclareExportDeclaration',
38
- // $FlowFixMe[incompatible-call]
38
+ // $FlowFixMe[incompatible-type]
39
39
  declaration: asDetachedNode(props.declaration),
40
40
  specifiers: [],
41
41
  source: null,
@@ -59,7 +59,7 @@ export function DeclareExportDeclarationNamedWithDeclaration(props: {
59
59
  props.parent,
60
60
  {
61
61
  type: 'DeclareExportDeclaration',
62
- // $FlowFixMe[incompatible-call]
62
+ // $FlowFixMe[incompatible-type]
63
63
  declaration: asDetachedNode(props.declaration),
64
64
  specifiers: [],
65
65
  source: null,
@@ -90,7 +90,7 @@ export function DeclareExportDeclarationNamedWithSpecifiers(props: {
90
90
  type: 'DeclareExportDeclaration',
91
91
  declaration: null,
92
92
  specifiers: props.specifiers.map(n => asDetachedNode(n)),
93
- // $FlowFixMe[incompatible-call]
93
+ // $FlowFixMe[incompatible-type]
94
94
  source: asDetachedNode(props.source),
95
95
  default: false,
96
96
  },
@@ -20,7 +20,7 @@ var _detachedNode = require("../../detachedNode");
20
20
  function ExportNamedDeclarationWithDeclaration(props) {
21
21
  const node = (0, _detachedNode.detachedProps)(props.parent, {
22
22
  type: 'ExportNamedDeclaration',
23
- // $FlowFixMe[incompatible-call]
23
+ // $FlowFixMe[incompatible-type]
24
24
  declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
25
25
  specifiers: [],
26
26
  source: null,
@@ -35,7 +35,7 @@ function ExportNamedDeclarationWithSpecifiers(props) {
35
35
  type: 'ExportNamedDeclaration',
36
36
  declaration: null,
37
37
  specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNode)(n)),
38
- // $FlowFixMe[incompatible-call]
38
+ // $FlowFixMe[incompatible-type]
39
39
  source: (0, _detachedNode.asDetachedNode)(props.source),
40
40
  exportKind: props.exportKind
41
41
  });
@@ -35,7 +35,7 @@ export function ExportNamedDeclarationWithDeclaration(props: {
35
35
  props.parent,
36
36
  {
37
37
  type: 'ExportNamedDeclaration',
38
- // $FlowFixMe[incompatible-call]
38
+ // $FlowFixMe[incompatible-type]
39
39
  declaration: asDetachedNode(props.declaration),
40
40
  specifiers: [],
41
41
  source: null,
@@ -67,7 +67,7 @@ export function ExportNamedDeclarationWithSpecifiers(props: {
67
67
  type: 'ExportNamedDeclaration',
68
68
  declaration: null,
69
69
  specifiers: props.specifiers.map(n => asDetachedNode(n)),
70
- // $FlowFixMe[incompatible-call]
70
+ // $FlowFixMe[incompatible-type]
71
71
  source: asDetachedNode(props.source),
72
72
  exportKind: props.exportKind,
73
73
  },
@@ -48,7 +48,7 @@ function ObjectTypePropertySignature(props) {
48
48
  proto: (_props$proto2 = props.proto) != null ? _props$proto2 : false,
49
49
  static: (_props$static2 = props.static) != null ? _props$static2 : false,
50
50
  value: (0, _detachedNode.asDetachedNode)(props.value),
51
- // $FlowFixMe[incompatible-call]
51
+ // $FlowFixMe[incompatible-type]
52
52
  variance: (0, _detachedNode.asDetachedNode)(props.variance)
53
53
  });
54
54
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -72,7 +72,7 @@ export function ObjectTypePropertySignature(props: {
72
72
  proto: props.proto ?? false,
73
73
  static: props.static ?? false,
74
74
  value: asDetachedNode(props.value),
75
- // $FlowFixMe[incompatible-call]
75
+ // $FlowFixMe[incompatible-type]
76
76
  variance: asDetachedNode(props.variance),
77
77
  });
78
78
  setParentPointersInDirectChildren(node);
@@ -31,11 +31,11 @@ function ArrowFunctionExpression(props) {
31
31
  expression: props.body.type !== 'BlockStatement',
32
32
  params: props.params.map(n => (0, _detachedNode.asDetachedNode)(n)),
33
33
  body: (0, _detachedNode.asDetachedNode)(props.body),
34
- // $FlowFixMe[incompatible-call]
34
+ // $FlowFixMe[incompatible-type]
35
35
  typeParameters: (0, _detachedNode.asDetachedNode)(props.typeParameters),
36
- // $FlowFixMe[incompatible-call]
36
+ // $FlowFixMe[incompatible-type]
37
37
  returnType: (0, _detachedNode.asDetachedNode)(props.returnType),
38
- // $FlowFixMe[incompatible-call]
38
+ // $FlowFixMe[incompatible-type]
39
39
  predicate: (0, _detachedNode.asDetachedNode)(props.predicate),
40
40
  async: props.async
41
41
  });
@@ -48,13 +48,13 @@ function ClassDeclaration(props) {
48
48
 
49
49
  const node = (0, _detachedNode.detachedProps)(props.parent, {
50
50
  type: 'ClassDeclaration',
51
- // $FlowFixMe[incompatible-call]
51
+ // $FlowFixMe[incompatible-type]
52
52
  id: (0, _detachedNode.asDetachedNode)(props.id),
53
- // $FlowFixMe[incompatible-call]
53
+ // $FlowFixMe[incompatible-type]
54
54
  typeParameters: (0, _detachedNode.asDetachedNode)(props.typeParameters),
55
- // $FlowFixMe[incompatible-call]
55
+ // $FlowFixMe[incompatible-type]
56
56
  superClass: (0, _detachedNode.asDetachedNode)(props.superClass),
57
- // $FlowFixMe[incompatible-call]
57
+ // $FlowFixMe[incompatible-type]
58
58
  superTypeParameters: (0, _detachedNode.asDetachedNode)(props.superTypeParameters),
59
59
  decorators: ((_props$decorators = props.decorators) != null ? _props$decorators : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
60
60
  implements: ((_props$implements = props.implements) != null ? _props$implements : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
@@ -85,7 +85,7 @@ function Identifier(props) {
85
85
  type: 'Identifier',
86
86
  name: props.name,
87
87
  optional: (_props$optional = props.optional) != null ? _props$optional : false,
88
- // $FlowFixMe[incompatible-call]
88
+ // $FlowFixMe[incompatible-type]
89
89
  typeAnnotation: (0, _detachedNode.asDetachedNode)(props.typeAnnotation)
90
90
  });
91
91
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -103,7 +103,7 @@ function Program(props) {
103
103
  body: props.body.map(n => (0, _detachedNode.asDetachedNode)(n)),
104
104
  tokens: (_props$tokens = props.tokens) != null ? _props$tokens : [],
105
105
  comments: (_props$comments = props.comments) != null ? _props$comments : [],
106
- interpreter: props.interpreter != null ? // $FlowFixMe[incompatible-call]
106
+ interpreter: props.interpreter != null ? // $FlowFixMe[incompatible-type]
107
107
  (0, _detachedNode.asDetachedNode)({
108
108
  type: 'InterpreterDirective',
109
109
  value: props.interpreter
@@ -126,7 +126,7 @@ function DeclareFunction(props) {
126
126
  typeAnnotation: (0, _detachedNode.asDetachedNode)(props.functionType)
127
127
  })
128
128
  }),
129
- // $FlowFixMe[incompatible-call]
129
+ // $FlowFixMe[incompatible-type]
130
130
  predicate: (0, _detachedNode.asDetachedNode)(props.predicate)
131
131
  });
132
132
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -65,11 +65,11 @@ export function ArrowFunctionExpression(props: {
65
65
  expression: props.body.type !== 'BlockStatement',
66
66
  params: props.params.map(n => asDetachedNode(n)),
67
67
  body: asDetachedNode(props.body),
68
- // $FlowFixMe[incompatible-call]
68
+ // $FlowFixMe[incompatible-type]
69
69
  typeParameters: asDetachedNode(props.typeParameters),
70
- // $FlowFixMe[incompatible-call]
70
+ // $FlowFixMe[incompatible-type]
71
71
  returnType: asDetachedNode(props.returnType),
72
- // $FlowFixMe[incompatible-call]
72
+ // $FlowFixMe[incompatible-type]
73
73
  predicate: asDetachedNode(props.predicate),
74
74
  async: props.async,
75
75
  });
@@ -100,13 +100,13 @@ export function ClassDeclaration(props: {
100
100
  }): DetachedNode<ClassDeclarationType> {
101
101
  const node = detachedProps<ClassDeclarationType>(props.parent, {
102
102
  type: 'ClassDeclaration',
103
- // $FlowFixMe[incompatible-call]
103
+ // $FlowFixMe[incompatible-type]
104
104
  id: asDetachedNode(props.id),
105
- // $FlowFixMe[incompatible-call]
105
+ // $FlowFixMe[incompatible-type]
106
106
  typeParameters: asDetachedNode(props.typeParameters),
107
- // $FlowFixMe[incompatible-call]
107
+ // $FlowFixMe[incompatible-type]
108
108
  superClass: asDetachedNode(props.superClass),
109
- // $FlowFixMe[incompatible-call]
109
+ // $FlowFixMe[incompatible-type]
110
110
  superTypeParameters: asDetachedNode(props.superTypeParameters),
111
111
  decorators: (props.decorators ?? []).map(n => asDetachedNode(n)),
112
112
  implements: (props.implements ?? []).map(n => asDetachedNode(n)),
@@ -151,7 +151,7 @@ export function Identifier(props: {
151
151
  type: 'Identifier',
152
152
  name: props.name,
153
153
  optional: props.optional ?? false,
154
- // $FlowFixMe[incompatible-call]
154
+ // $FlowFixMe[incompatible-type]
155
155
  typeAnnotation: asDetachedNode(props.typeAnnotation),
156
156
  });
157
157
  setParentPointersInDirectChildren(node);
@@ -179,7 +179,7 @@ export function Program(props: {
179
179
  comments: props.comments ?? [],
180
180
  interpreter:
181
181
  props.interpreter != null
182
- ? // $FlowFixMe[incompatible-call]
182
+ ? // $FlowFixMe[incompatible-type]
183
183
  asDetachedNode<InterpreterDirectiveType>({
184
184
  type: 'InterpreterDirective',
185
185
  value: props.interpreter,
@@ -211,7 +211,7 @@ export function DeclareFunction(props: {
211
211
  typeAnnotation: asDetachedNode(props.functionType),
212
212
  }),
213
213
  }),
214
- // $FlowFixMe[incompatible-call]
214
+ // $FlowFixMe[incompatible-type]
215
215
  predicate: asDetachedNode(props.predicate),
216
216
  });
217
217
  setParentPointersInDirectChildren(node);
@@ -19,7 +19,7 @@ var _detachedNode = require("../../detachedNode");
19
19
  */
20
20
  function LineComment(props) {
21
21
  // $FlowExpectedError[prop-missing]
22
- // $FlowExpectedError[incompatible-return]
22
+ // $FlowExpectedError[incompatible-type]
23
23
  return (0, _detachedNode.detachedProps)(undefined, {
24
24
  type: 'Line',
25
25
  value: props.value
@@ -28,7 +28,7 @@ function LineComment(props) {
28
28
 
29
29
  function BlockComment(props) {
30
30
  // $FlowExpectedError[prop-missing]
31
- // $FlowExpectedError[incompatible-return]
31
+ // $FlowExpectedError[incompatible-type]
32
32
  return (0, _detachedNode.detachedProps)(undefined, {
33
33
  type: 'Block',
34
34
  value: props.value
@@ -21,7 +21,7 @@ var _detachedNode = require("../../detachedNode");
21
21
  function DeclareExportDefaultDeclaration(props) {
22
22
  const node = (0, _detachedNode.detachedProps)(props.parent, {
23
23
  type: 'DeclareExportDeclaration',
24
- // $FlowFixMe[incompatible-call]
24
+ // $FlowFixMe[incompatible-type]
25
25
  declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
26
26
  specifiers: [],
27
27
  source: null,
@@ -34,7 +34,7 @@ function DeclareExportDefaultDeclaration(props) {
34
34
  function DeclareExportDeclarationNamedWithDeclaration(props) {
35
35
  const node = (0, _detachedNode.detachedProps)(props.parent, {
36
36
  type: 'DeclareExportDeclaration',
37
- // $FlowFixMe[incompatible-call]
37
+ // $FlowFixMe[incompatible-type]
38
38
  declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
39
39
  specifiers: [],
40
40
  source: null,
@@ -49,7 +49,7 @@ function DeclareExportDeclarationNamedWithSpecifiers(props) {
49
49
  type: 'DeclareExportDeclaration',
50
50
  declaration: null,
51
51
  specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNode)(n)),
52
- // $FlowFixMe[incompatible-call]
52
+ // $FlowFixMe[incompatible-type]
53
53
  source: (0, _detachedNode.asDetachedNode)(props.source),
54
54
  default: false
55
55
  });
@@ -20,7 +20,7 @@ var _detachedNode = require("../../detachedNode");
20
20
  function ExportNamedDeclarationWithDeclaration(props) {
21
21
  const node = (0, _detachedNode.detachedProps)(props.parent, {
22
22
  type: 'ExportNamedDeclaration',
23
- // $FlowFixMe[incompatible-call]
23
+ // $FlowFixMe[incompatible-type]
24
24
  declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
25
25
  specifiers: [],
26
26
  source: null,
@@ -35,7 +35,7 @@ function ExportNamedDeclarationWithSpecifiers(props) {
35
35
  type: 'ExportNamedDeclaration',
36
36
  declaration: null,
37
37
  specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNode)(n)),
38
- // $FlowFixMe[incompatible-call]
38
+ // $FlowFixMe[incompatible-type]
39
39
  source: (0, _detachedNode.asDetachedNode)(props.source),
40
40
  exportKind: props.exportKind
41
41
  });
@@ -48,7 +48,7 @@ function ObjectTypePropertySignature(props) {
48
48
  proto: (_props$proto2 = props.proto) != null ? _props$proto2 : false,
49
49
  static: (_props$static2 = props.static) != null ? _props$static2 : false,
50
50
  value: (0, _detachedNode.asDetachedNode)(props.value),
51
- // $FlowFixMe[incompatible-call]
51
+ // $FlowFixMe[incompatible-type]
52
52
  variance: (0, _detachedNode.asDetachedNode)(props.variance)
53
53
  });
54
54
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -31,11 +31,11 @@ function ArrowFunctionExpression(props) {
31
31
  expression: props.body.type !== 'BlockStatement',
32
32
  params: props.params.map(n => (0, _detachedNode.asDetachedNode)(n)),
33
33
  body: (0, _detachedNode.asDetachedNode)(props.body),
34
- // $FlowFixMe[incompatible-call]
34
+ // $FlowFixMe[incompatible-type]
35
35
  typeParameters: (0, _detachedNode.asDetachedNode)(props.typeParameters),
36
- // $FlowFixMe[incompatible-call]
36
+ // $FlowFixMe[incompatible-type]
37
37
  returnType: (0, _detachedNode.asDetachedNode)(props.returnType),
38
- // $FlowFixMe[incompatible-call]
38
+ // $FlowFixMe[incompatible-type]
39
39
  predicate: (0, _detachedNode.asDetachedNode)(props.predicate),
40
40
  async: props.async
41
41
  });
@@ -48,13 +48,13 @@ function ClassDeclaration(props) {
48
48
 
49
49
  const node = (0, _detachedNode.detachedProps)(props.parent, {
50
50
  type: 'ClassDeclaration',
51
- // $FlowFixMe[incompatible-call]
51
+ // $FlowFixMe[incompatible-type]
52
52
  id: (0, _detachedNode.asDetachedNode)(props.id),
53
- // $FlowFixMe[incompatible-call]
53
+ // $FlowFixMe[incompatible-type]
54
54
  typeParameters: (0, _detachedNode.asDetachedNode)(props.typeParameters),
55
- // $FlowFixMe[incompatible-call]
55
+ // $FlowFixMe[incompatible-type]
56
56
  superClass: (0, _detachedNode.asDetachedNode)(props.superClass),
57
- // $FlowFixMe[incompatible-call]
57
+ // $FlowFixMe[incompatible-type]
58
58
  superTypeParameters: (0, _detachedNode.asDetachedNode)(props.superTypeParameters),
59
59
  decorators: ((_props$decorators = props.decorators) != null ? _props$decorators : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
60
60
  implements: ((_props$implements = props.implements) != null ? _props$implements : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
@@ -85,7 +85,7 @@ function Identifier(props) {
85
85
  type: 'Identifier',
86
86
  name: props.name,
87
87
  optional: (_props$optional = props.optional) != null ? _props$optional : false,
88
- // $FlowFixMe[incompatible-call]
88
+ // $FlowFixMe[incompatible-type]
89
89
  typeAnnotation: (0, _detachedNode.asDetachedNode)(props.typeAnnotation)
90
90
  });
91
91
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -103,7 +103,7 @@ function Program(props) {
103
103
  body: props.body.map(n => (0, _detachedNode.asDetachedNode)(n)),
104
104
  tokens: (_props$tokens = props.tokens) != null ? _props$tokens : [],
105
105
  comments: (_props$comments = props.comments) != null ? _props$comments : [],
106
- interpreter: props.interpreter != null ? // $FlowFixMe[incompatible-call]
106
+ interpreter: props.interpreter != null ? // $FlowFixMe[incompatible-type]
107
107
  (0, _detachedNode.asDetachedNode)({
108
108
  type: 'InterpreterDirective',
109
109
  value: props.interpreter
@@ -126,7 +126,7 @@ function DeclareFunction(props) {
126
126
  typeAnnotation: (0, _detachedNode.asDetachedNode)(props.functionType)
127
127
  })
128
128
  }),
129
- // $FlowFixMe[incompatible-call]
129
+ // $FlowFixMe[incompatible-type]
130
130
  predicate: (0, _detachedNode.asDetachedNode)(props.predicate)
131
131
  });
132
132
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -76,7 +76,7 @@ function getTransformContext() {
76
76
  const node = node_;
77
77
 
78
78
  if (node == null) {
79
- // $FlowExpectedError[incompatible-return]
79
+ // $FlowExpectedError[incompatible-type]
80
80
  return node;
81
81
  }
82
82
 
@@ -182,7 +182,7 @@ function addComment(node, comment, placement) {
182
182
  }
183
183
 
184
184
  function cloneComment(comment) {
185
- // $FlowExpectedError[incompatible-return]
185
+ // $FlowExpectedError[incompatible-type]
186
186
  return {
187
187
  type: comment.type,
188
188
  value: comment.value,
@@ -192,7 +192,7 @@ function cloneComment(comment) {
192
192
  }
193
193
 
194
194
  function cloneCommentWithMarkers(comment) {
195
- // $FlowExpectedError[incompatible-return]
195
+ // $FlowExpectedError[incompatible-type]
196
196
  return {
197
197
  type: comment.type,
198
198
  value: comment.value,
@@ -72,7 +72,7 @@ function performInsertStatementMutation(mutationContext, mutation) {
72
72
  return insertionParent.parent;
73
73
  }
74
74
 
75
- const statementsToInsert = // $FlowExpectedError[incompatible-cast] -- this is enforced by isValidModuleDeclarationParent above
75
+ const statementsToInsert = // $FlowExpectedError[incompatible-type] -- this is enforced by isValidModuleDeclarationParent above
76
76
  mutation.nodesToInsert;
77
77
  const {
78
78
  parent,
@@ -67,7 +67,7 @@ function performReplaceStatementWithManyMutation(mutationContext, mutation) {
67
67
  return replacementParent.parent;
68
68
  }
69
69
 
70
- const statementsToReplaceWith = // $FlowExpectedError[incompatible-cast] -- this is enforced by isValidModuleDeclarationParent above
70
+ const statementsToReplaceWith = // $FlowExpectedError[incompatible-type] -- this is enforced by isValidModuleDeclarationParent above
71
71
  mutation.nodesToReplaceWith; // we need to wrap the nodes in a BlockStatement as before there was only 1 node
72
72
 
73
73
  const blockStatement = t.BlockStatement({
@@ -31,7 +31,7 @@ function isValidModuleDeclarationParent(target, nodesToInsertOrReplace) {
31
31
  }
32
32
 
33
33
  for (const node of nodesToInsertOrReplace) {
34
- if (!isModuleDeclaration( // $FlowExpectedError[incompatible-cast]
34
+ if (!isModuleDeclaration( // $FlowExpectedError[incompatible-type]
35
35
  node)) {
36
36
  continue;
37
37
  }
@@ -44,24 +44,39 @@ async function print(ast, originalCode, prettierOptions = {}, visitorKeys) {
44
44
 
45
45
  const codeForPrinting = (0, _comments.mutateESTreeASTCommentsForPrettier)(program, originalCode); // Fix up the AST to match what prettier expects.
46
46
 
47
- (0, _hermesParser.mutateESTreeASTForPrettier)(program, visitorKeys); // Lazy require this module as it only exists in prettier v3.
48
-
49
- const prettierFlowPlugin = require('prettier/plugins/flow');
47
+ (0, _hermesParser.mutateESTreeASTForPrettier)(program, visitorKeys);
48
+ let pluginParserName = 'flow';
49
+ let pluginParser;
50
+ let pluginPrinter;
51
+
52
+ try {
53
+ // Use prettier-plugin-hermes-parser if we can. It has latest Flow syntax support.
54
+ // $FlowExpectedError[untyped-import]
55
+ const prettierHermesPlugin = await Promise.resolve().then(() => _interopRequireWildcard(require('prettier-plugin-hermes-parser')));
56
+ pluginParser = prettierHermesPlugin.parsers.hermes;
57
+ pluginPrinter = prettierHermesPlugin.printers;
58
+ pluginParserName = 'hermes';
59
+ } catch {
60
+ const prettierFlowPlugin = require('prettier/plugins/flow');
61
+
62
+ pluginParser = prettierFlowPlugin.parsers.flow;
63
+ }
50
64
 
51
65
  return prettier.format(codeForPrinting, // $FlowExpectedError[incompatible-exact] - we don't want to create a dependency on the prettier types
52
66
  { ...prettierOptions,
53
- parser: 'flow',
67
+ parser: pluginParserName,
54
68
  requirePragma: false,
55
69
  plugins: [{
56
70
  parsers: {
57
- flow: { ...prettierFlowPlugin.parsers.flow,
71
+ [pluginParserName]: { ...pluginParser,
58
72
 
59
73
  parse() {
60
74
  return program;
61
75
  }
62
76
 
63
77
  }
64
- }
78
+ },
79
+ printers: pluginPrinter
65
80
  }]
66
81
  });
67
82
  }
@@ -69,7 +69,7 @@ function getPossibleTypes(parsedSelector) {
69
69
  case 'identifier':
70
70
  if (!(parsedSelector.value in _hermesParser.FlowVisitorKeys)) {
71
71
  throw new Error(`Unexpected selector ${parsedSelector.value}`);
72
- } // $FlowExpectedError[incompatible-return]
72
+ } // $FlowExpectedError[incompatible-type]
73
73
 
74
74
 
75
75
  return [parsedSelector.value];
@@ -76,7 +76,7 @@ function getTransformContext() {
76
76
  const node = node_;
77
77
 
78
78
  if (node == null) {
79
- // $FlowExpectedError[incompatible-return]
79
+ // $FlowExpectedError[incompatible-type]
80
80
  return node;
81
81
  }
82
82
 
@@ -366,7 +366,7 @@ export function getTransformContext(): TransformContextAdditions {
366
366
  return nodes.map((node_: ?T): DetachedNode<?ESNode> => {
367
367
  const node: ?ESNode = node_;
368
368
  if (node == null) {
369
- // $FlowExpectedError[incompatible-return]
369
+ // $FlowExpectedError[incompatible-type]
370
370
  return node;
371
371
  }
372
372
  return shallowCloneNode<ESNode>(node, {});
@@ -182,7 +182,7 @@ function addComment(node, comment, placement) {
182
182
  }
183
183
 
184
184
  function cloneComment(comment) {
185
- // $FlowExpectedError[incompatible-return]
185
+ // $FlowExpectedError[incompatible-type]
186
186
  return {
187
187
  type: comment.type,
188
188
  value: comment.value,
@@ -192,7 +192,7 @@ function cloneComment(comment) {
192
192
  }
193
193
 
194
194
  function cloneCommentWithMarkers(comment) {
195
- // $FlowExpectedError[incompatible-return]
195
+ // $FlowExpectedError[incompatible-type]
196
196
  return {
197
197
  type: comment.type,
198
198
  value: comment.value,
@@ -205,7 +205,7 @@ export function addComment(
205
205
  }
206
206
 
207
207
  export function cloneComment<T: Comment>(comment: T): T {
208
- // $FlowExpectedError[incompatible-return]
208
+ // $FlowExpectedError[incompatible-type]
209
209
  return {
210
210
  type: comment.type,
211
211
  value: comment.value,
@@ -215,7 +215,7 @@ export function cloneComment<T: Comment>(comment: T): T {
215
215
  }
216
216
 
217
217
  export function cloneCommentWithMarkers<T: Comment>(comment: T): T {
218
- // $FlowExpectedError[incompatible-return]
218
+ // $FlowExpectedError[incompatible-type]
219
219
  return {
220
220
  type: comment.type,
221
221
  value: comment.value,
@@ -72,7 +72,7 @@ function performInsertStatementMutation(mutationContext, mutation) {
72
72
  return insertionParent.parent;
73
73
  }
74
74
 
75
- const statementsToInsert = // $FlowExpectedError[incompatible-cast] -- this is enforced by isValidModuleDeclarationParent above
75
+ const statementsToInsert = // $FlowExpectedError[incompatible-type] -- this is enforced by isValidModuleDeclarationParent above
76
76
  mutation.nodesToInsert;
77
77
  const {
78
78
  parent,
@@ -95,7 +95,7 @@ export function performInsertStatementMutation(
95
95
  }
96
96
 
97
97
  const statementsToInsert =
98
- // $FlowExpectedError[incompatible-cast] -- this is enforced by isValidModuleDeclarationParent above
98
+ // $FlowExpectedError[incompatible-type] -- this is enforced by isValidModuleDeclarationParent above
99
99
  (mutation.nodesToInsert: $ReadOnlyArray<DetachedNode<Statement>>);
100
100
 
101
101
  const {parent, key} = insertionParent;
@@ -67,7 +67,7 @@ function performReplaceStatementWithManyMutation(mutationContext, mutation) {
67
67
  return replacementParent.parent;
68
68
  }
69
69
 
70
- const statementsToReplaceWith = // $FlowExpectedError[incompatible-cast] -- this is enforced by isValidModuleDeclarationParent above
70
+ const statementsToReplaceWith = // $FlowExpectedError[incompatible-type] -- this is enforced by isValidModuleDeclarationParent above
71
71
  mutation.nodesToReplaceWith; // we need to wrap the nodes in a BlockStatement as before there was only 1 node
72
72
 
73
73
  const blockStatement = t.BlockStatement({
@@ -88,7 +88,7 @@ export function performReplaceStatementWithManyMutation(
88
88
  }
89
89
 
90
90
  const statementsToReplaceWith =
91
- // $FlowExpectedError[incompatible-cast] -- this is enforced by isValidModuleDeclarationParent above
91
+ // $FlowExpectedError[incompatible-type] -- this is enforced by isValidModuleDeclarationParent above
92
92
  (mutation.nodesToReplaceWith: $ReadOnlyArray<DetachedNode<Statement>>);
93
93
 
94
94
  // we need to wrap the nodes in a BlockStatement as before there was only 1 node
@@ -31,7 +31,7 @@ function isValidModuleDeclarationParent(target, nodesToInsertOrReplace) {
31
31
  }
32
32
 
33
33
  for (const node of nodesToInsertOrReplace) {
34
- if (!isModuleDeclaration( // $FlowExpectedError[incompatible-cast]
34
+ if (!isModuleDeclaration( // $FlowExpectedError[incompatible-type]
35
35
  node)) {
36
36
  continue;
37
37
  }
@@ -57,7 +57,7 @@ export function isValidModuleDeclarationParent(
57
57
  for (const node of nodesToInsertOrReplace) {
58
58
  if (
59
59
  !isModuleDeclaration(
60
- // $FlowExpectedError[incompatible-cast]
60
+ // $FlowExpectedError[incompatible-type]
61
61
  (node: ESNode),
62
62
  )
63
63
  ) {
@@ -44,24 +44,39 @@ async function print(ast, originalCode, prettierOptions = {}, visitorKeys) {
44
44
 
45
45
  const codeForPrinting = (0, _comments.mutateESTreeASTCommentsForPrettier)(program, originalCode); // Fix up the AST to match what prettier expects.
46
46
 
47
- (0, _hermesParser.mutateESTreeASTForPrettier)(program, visitorKeys); // Lazy require this module as it only exists in prettier v3.
48
-
49
- const prettierFlowPlugin = require('prettier/plugins/flow');
47
+ (0, _hermesParser.mutateESTreeASTForPrettier)(program, visitorKeys);
48
+ let pluginParserName = 'flow';
49
+ let pluginParser;
50
+ let pluginPrinter;
51
+
52
+ try {
53
+ // Use prettier-plugin-hermes-parser if we can. It has latest Flow syntax support.
54
+ // $FlowExpectedError[untyped-import]
55
+ const prettierHermesPlugin = await Promise.resolve().then(() => _interopRequireWildcard(require('prettier-plugin-hermes-parser')));
56
+ pluginParser = prettierHermesPlugin.parsers.hermes;
57
+ pluginPrinter = prettierHermesPlugin.printers;
58
+ pluginParserName = 'hermes';
59
+ } catch {
60
+ const prettierFlowPlugin = require('prettier/plugins/flow');
61
+
62
+ pluginParser = prettierFlowPlugin.parsers.flow;
63
+ }
50
64
 
51
65
  return prettier.format(codeForPrinting, // $FlowExpectedError[incompatible-exact] - we don't want to create a dependency on the prettier types
52
66
  { ...prettierOptions,
53
- parser: 'flow',
67
+ parser: pluginParserName,
54
68
  requirePragma: false,
55
69
  plugins: [{
56
70
  parsers: {
57
- flow: { ...prettierFlowPlugin.parsers.flow,
71
+ [pluginParserName]: { ...pluginParser,
58
72
 
59
73
  parse() {
60
74
  return program;
61
75
  }
62
76
 
63
77
  }
64
- }
78
+ },
79
+ printers: pluginPrinter
65
80
  }]
66
81
  });
67
82
  }
@@ -47,25 +47,39 @@ export async function print(
47
47
  // Fix up the AST to match what prettier expects.
48
48
  mutateESTreeASTForPrettier(program, visitorKeys);
49
49
 
50
- // Lazy require this module as it only exists in prettier v3.
51
- const prettierFlowPlugin = require('prettier/plugins/flow');
50
+ let pluginParserName = 'flow';
51
+ let pluginParser;
52
+ let pluginPrinter;
53
+ try {
54
+ // Use prettier-plugin-hermes-parser if we can. It has latest Flow syntax support.
55
+ // $FlowExpectedError[untyped-import]
56
+ const prettierHermesPlugin = await import('prettier-plugin-hermes-parser');
57
+ pluginParser = prettierHermesPlugin.parsers.hermes;
58
+ pluginPrinter = prettierHermesPlugin.printers;
59
+ pluginParserName = 'hermes';
60
+ } catch {
61
+ const prettierFlowPlugin = require('prettier/plugins/flow');
62
+ pluginParser = prettierFlowPlugin.parsers.flow;
63
+ }
64
+
52
65
  return prettier.format(
53
66
  codeForPrinting,
54
67
  // $FlowExpectedError[incompatible-exact] - we don't want to create a dependency on the prettier types
55
68
  {
56
69
  ...prettierOptions,
57
- parser: 'flow',
70
+ parser: pluginParserName,
58
71
  requirePragma: false,
59
72
  plugins: [
60
73
  {
61
74
  parsers: {
62
- flow: {
63
- ...prettierFlowPlugin.parsers.flow,
75
+ [pluginParserName]: {
76
+ ...pluginParser,
64
77
  parse() {
65
78
  return program;
66
79
  },
67
80
  },
68
81
  },
82
+ printers: pluginPrinter,
69
83
  },
70
84
  ],
71
85
  },
@@ -69,7 +69,7 @@ function getPossibleTypes(parsedSelector) {
69
69
  case 'identifier':
70
70
  if (!(parsedSelector.value in _hermesParser.FlowVisitorKeys)) {
71
71
  throw new Error(`Unexpected selector ${parsedSelector.value}`);
72
- } // $FlowExpectedError[incompatible-return]
72
+ } // $FlowExpectedError[incompatible-type]
73
73
 
74
74
 
75
75
  return [parsedSelector.value];
@@ -77,7 +77,7 @@ function getPossibleTypes(parsedSelector: Selector): ?Array<ESNode['type']> {
77
77
  if (!(parsedSelector.value in FlowVisitorKeys)) {
78
78
  throw new Error(`Unexpected selector ${parsedSelector.value}`);
79
79
  }
80
- // $FlowExpectedError[incompatible-return]
80
+ // $FlowExpectedError[incompatible-type]
81
81
  return [parsedSelector.value];
82
82
 
83
83
  case 'matches': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-transform",
3
- "version": "0.31.2",
3
+ "version": "0.32.0",
4
4
  "description": "Tools built on top of Hermes-ESTree to enable codebase transformation",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -12,13 +12,19 @@
12
12
  "@babel/code-frame": "^7.16.0",
13
13
  "esquery": "^1.4.0",
14
14
  "flow-enums-runtime": "^0.0.6",
15
- "hermes-eslint": "0.31.2",
16
- "hermes-estree": "0.31.2",
17
- "hermes-parser": "0.31.2",
15
+ "hermes-eslint": "0.32.0",
16
+ "hermes-estree": "0.32.0",
17
+ "hermes-parser": "0.32.0",
18
18
  "string-width": "4.2.3"
19
19
  },
20
20
  "peerDependencies": {
21
- "prettier": "^3.0.0"
21
+ "prettier": "^3.0.0",
22
+ "prettier-plugin-hermes-parser": "*"
23
+ },
24
+ "peerDependenciesMeta": {
25
+ "prettier-plugin-hermes-parser": {
26
+ "optional": true
27
+ }
22
28
  },
23
29
  "files": [
24
30
  "dist",