hermes-parser 0.23.0 → 0.24.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.
@@ -1093,7 +1093,8 @@ function transformProgram(program, options) {
1093
1093
  leave() {},
1094
1094
 
1095
1095
  visitorKeys: FlowESTreeAndBabelVisitorKeys
1096
- });
1096
+ }); // $FlowFixMe[incompatible-type]
1097
+
1097
1098
 
1098
1099
  if ((resultNode == null ? void 0 : resultNode.type) === 'File') {
1099
1100
  return resultNode;
@@ -1248,6 +1248,7 @@ export function transformProgram(
1248
1248
  visitorKeys: FlowESTreeAndBabelVisitorKeys,
1249
1249
  });
1250
1250
 
1251
+ // $FlowFixMe[incompatible-type]
1251
1252
  if (resultNode?.type === 'File') {
1252
1253
  return resultNode;
1253
1254
  }
@@ -43,6 +43,7 @@ function getParentKey(target, parent, visitorKeys) {
43
43
  }
44
44
  } else if (Array.isArray(parent[key])) {
45
45
  for (let i = 0; i < parent[key].length; i += 1) {
46
+ // $FlowExpectedError[invalid-tuple-index]
46
47
  const current = parent[key][i];
47
48
 
48
49
  if (current === target) {
@@ -104,6 +105,7 @@ function removeNodeOnParent(originalNode, originalNodeParent, visitorKeys) {
104
105
  function setParentPointersInDirectChildren(node, visitorKeys) {
105
106
  for (const key of (0, _getVisitorKeys.getVisitorKeys)(node, visitorKeys)) {
106
107
  if ((0, _getVisitorKeys.isNode)(node[key])) {
108
+ // $FlowExpectedError[cannot-write]
107
109
  node[key].parent = node;
108
110
  } else if (Array.isArray(node[key])) {
109
111
  for (const child of node[key]) {
@@ -53,6 +53,7 @@ function getParentKey(
53
53
  }
54
54
  } else if (Array.isArray(parent[key])) {
55
55
  for (let i = 0; i < parent[key].length; i += 1) {
56
+ // $FlowExpectedError[invalid-tuple-index]
56
57
  const current = parent[key][i];
57
58
  if (current === target) {
58
59
  return {type: 'array', node: parent, key, targetIndex: i};
@@ -132,6 +133,7 @@ export function setParentPointersInDirectChildren(
132
133
  ): void {
133
134
  for (const key: $FlowFixMe of getVisitorKeys(node, visitorKeys)) {
134
135
  if (isNode(node[key])) {
136
+ // $FlowExpectedError[cannot-write]
135
137
  node[key].parent = node;
136
138
  } else if (Array.isArray(node[key])) {
137
139
  for (const child of node[key]) {
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  *
8
- * @format
8
+ * @noformat
9
9
  */
10
10
  'use strict';
11
11
 
@@ -19,8 +19,9 @@ var _ESTreeVisitorKeys = _interopRequireDefault(require("../generated/ESTreeVisi
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
- // $FlowFixMe[deprecated-type]
23
- function isNode(thing) {
22
+ function isNode(thing)
23
+ /*: implies thing is {+[string]: mixed} */
24
+ {
24
25
  return typeof thing === 'object' && thing != null && typeof thing.type === 'string';
25
26
  }
26
27
 
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @flow strict
8
- * @format
8
+ * @noformat
9
9
  */
10
10
 
11
11
  'use strict';
@@ -15,8 +15,7 @@ import type {VisitorKeys as VisitorKeysType} from '../generated/ESTreeVisitorKey
15
15
 
16
16
  import FlowVisitorKeys from '../generated/ESTreeVisitorKeys';
17
17
 
18
- // $FlowFixMe[deprecated-type]
19
- export function isNode(thing: mixed): boolean %checks {
18
+ export function isNode(thing: mixed) /*: implies thing is {+[string]: mixed} */ {
20
19
  return (
21
20
  typeof thing === 'object' && thing != null && typeof thing.type === 'string'
22
21
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-parser",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "A JavaScript parser built from the Hermes engine",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  "url": "git@github.com:facebook/hermes.git"
10
10
  },
11
11
  "dependencies": {
12
- "hermes-estree": "0.23.0"
12
+ "hermes-estree": "0.24.0"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@babel/parser": "7.7.4",