hermes-estree 0.9.0 → 0.10.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.
@@ -6,6 +6,13 @@
6
6
  *
7
7
  * @flow strict
8
8
  * @format
9
+ * @generated
10
+ */
11
+
12
+ /*
13
+ * !!! GENERATED FILE !!!
14
+ *
15
+ * Any manual changes to this file will be overwritten. To regenerate run `yarn build`.
9
16
  */
10
17
 
11
18
  // lint directives to let us do some basic validation of generated files
@@ -25,6 +32,7 @@ import type {
25
32
  AssignmentPattern,
26
33
  AwaitExpression,
27
34
  BigIntLiteralTypeAnnotation,
35
+ BigIntTypeAnnotation,
28
36
  BinaryExpression,
29
37
  BlockStatement,
30
38
  BooleanLiteralTypeAnnotation,
@@ -1044,6 +1052,9 @@ interface PropertyDefinition_With_variance extends PropertyDefinition {
1044
1052
  interface PropertyDefinition_With_typeAnnotation extends PropertyDefinition {
1045
1053
  +typeAnnotation: $NonMaybeType<PropertyDefinition['typeAnnotation']>;
1046
1054
  }
1055
+ interface PropertyDefinition_With_tsModifiers extends PropertyDefinition {
1056
+ +tsModifiers: $NonMaybeType<PropertyDefinition['tsModifiers']>;
1057
+ }
1047
1058
  interface QualifiedTypeIdentifier_With_qualification
1048
1059
  extends QualifiedTypeIdentifier {
1049
1060
  +qualification: $NonMaybeType<QualifiedTypeIdentifier['qualification']>;
@@ -1341,6 +1352,7 @@ export type ESQueryNodeSelectorsWithoutFallback = {
1341
1352
  +'BigIntLiteralTypeAnnotation[raw]'?: (
1342
1353
  node: BigIntLiteralTypeAnnotation_With_raw,
1343
1354
  ) => void,
1355
+ +BigIntTypeAnnotation?: (node: BigIntTypeAnnotation) => void,
1344
1356
  +BinaryExpression?: (node: BinaryExpression) => void,
1345
1357
  +'BinaryExpression[left]'?: (node: BinaryExpression_With_left) => void,
1346
1358
  +'BinaryExpression[right]'?: (node: BinaryExpression_With_right) => void,
@@ -1980,6 +1992,9 @@ export type ESQueryNodeSelectorsWithoutFallback = {
1980
1992
  +'PropertyDefinition[typeAnnotation]'?: (
1981
1993
  node: PropertyDefinition_With_typeAnnotation,
1982
1994
  ) => void,
1995
+ +'PropertyDefinition[tsModifiers]'?: (
1996
+ node: PropertyDefinition_With_tsModifiers,
1997
+ ) => void,
1983
1998
  +QualifiedTypeIdentifier?: (node: QualifiedTypeIdentifier) => void,
1984
1999
  +'QualifiedTypeIdentifier[qualification]'?: (
1985
2000
  node: QualifiedTypeIdentifier_With_qualification,
@@ -2185,6 +2200,7 @@ export type ESQueryNodeSelectorsWithoutFallback = {
2185
2200
  +'BigIntLiteralTypeAnnotation[raw]:exit'?: (
2186
2201
  node: BigIntLiteralTypeAnnotation_With_raw,
2187
2202
  ) => void,
2203
+ +'BigIntTypeAnnotation:exit'?: (node: BigIntTypeAnnotation) => void,
2188
2204
  +'BinaryExpression:exit'?: (node: BinaryExpression) => void,
2189
2205
  +'BinaryExpression[left]:exit'?: (node: BinaryExpression_With_left) => void,
2190
2206
  +'BinaryExpression[right]:exit'?: (node: BinaryExpression_With_right) => void,
@@ -2884,6 +2900,9 @@ export type ESQueryNodeSelectorsWithoutFallback = {
2884
2900
  +'PropertyDefinition[typeAnnotation]:exit'?: (
2885
2901
  node: PropertyDefinition_With_typeAnnotation,
2886
2902
  ) => void,
2903
+ +'PropertyDefinition[tsModifiers]:exit'?: (
2904
+ node: PropertyDefinition_With_tsModifiers,
2905
+ ) => void,
2887
2906
  +'QualifiedTypeIdentifier:exit'?: (node: QualifiedTypeIdentifier) => void,
2888
2907
  +'QualifiedTypeIdentifier[qualification]:exit'?: (
2889
2908
  node: QualifiedTypeIdentifier_With_qualification,
@@ -6,6 +6,13 @@
6
6
  *
7
7
  *
8
8
  * @format
9
+ * @generated
10
+ */
11
+
12
+ /*
13
+ * !!! GENERATED FILE !!!
14
+ *
15
+ * Any manual changes to this file will be overwritten. To regenerate run `yarn build`.
9
16
  */
10
17
  // lint directives to let us do some basic validation of generated files
11
18
 
@@ -30,6 +37,7 @@ exports.isAsyncKeyword = isAsyncKeyword;
30
37
  exports.isAwaitExpression = isAwaitExpression;
31
38
  exports.isAwaitKeyword = isAwaitKeyword;
32
39
  exports.isBigIntLiteralTypeAnnotation = isBigIntLiteralTypeAnnotation;
40
+ exports.isBigIntTypeAnnotation = isBigIntTypeAnnotation;
33
41
  exports.isBinaryExpression = isBinaryExpression;
34
42
  exports.isBitwiseANDEqualToken = isBitwiseANDEqualToken;
35
43
  exports.isBitwiseANDToken = isBitwiseANDToken;
@@ -313,6 +321,10 @@ function isBigIntLiteralTypeAnnotation(node) {
313
321
  return node.type === 'BigIntLiteralTypeAnnotation';
314
322
  }
315
323
 
324
+ function isBigIntTypeAnnotation(node) {
325
+ return node.type === 'BigIntTypeAnnotation';
326
+ }
327
+
316
328
  function isBinaryExpression(node) {
317
329
  return node.type === 'BinaryExpression';
318
330
  }
@@ -1218,47 +1230,47 @@ function isYieldToken(node) {
1218
1230
  }
1219
1231
 
1220
1232
  function isAsKeyword(node) {
1221
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'as';
1233
+ return node.type === 'Identifier' && node.name === 'as' || node.type === 'Keyword' && node.value === 'as';
1222
1234
  }
1223
1235
 
1224
1236
  function isAsyncKeyword(node) {
1225
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'async';
1237
+ return node.type === 'Identifier' && node.name === 'async' || node.type === 'Keyword' && node.value === 'async';
1226
1238
  }
1227
1239
 
1228
1240
  function isAwaitKeyword(node) {
1229
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'await';
1241
+ return node.type === 'Identifier' && node.name === 'await' || node.type === 'Keyword' && node.value === 'await';
1230
1242
  }
1231
1243
 
1232
1244
  function isDeclareKeyword(node) {
1233
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'declare';
1245
+ return node.type === 'Identifier' && node.name === 'declare' || node.type === 'Keyword' && node.value === 'declare';
1234
1246
  }
1235
1247
 
1236
1248
  function isFromKeyword(node) {
1237
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'from';
1249
+ return node.type === 'Identifier' && node.name === 'from' || node.type === 'Keyword' && node.value === 'from';
1238
1250
  }
1239
1251
 
1240
1252
  function isGetKeyword(node) {
1241
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'get';
1253
+ return node.type === 'Identifier' && node.name === 'get' || node.type === 'Keyword' && node.value === 'get';
1242
1254
  }
1243
1255
 
1244
1256
  function isLetKeyword(node) {
1245
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'let';
1257
+ return node.type === 'Identifier' && node.name === 'let' || node.type === 'Keyword' && node.value === 'let';
1246
1258
  }
1247
1259
 
1248
1260
  function isModuleKeyword(node) {
1249
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'module';
1261
+ return node.type === 'Identifier' && node.name === 'module' || node.type === 'Keyword' && node.value === 'module';
1250
1262
  }
1251
1263
 
1252
1264
  function isOfKeyword(node) {
1253
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'of';
1265
+ return node.type === 'Identifier' && node.name === 'of' || node.type === 'Keyword' && node.value === 'of';
1254
1266
  }
1255
1267
 
1256
1268
  function isSetKeyword(node) {
1257
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'set';
1269
+ return node.type === 'Identifier' && node.name === 'set' || node.type === 'Keyword' && node.value === 'set';
1258
1270
  }
1259
1271
 
1260
1272
  function isTypeKeyword(node) {
1261
- return (node.type === 'Identifier' || node.type === 'Keyword') && node.value === 'type';
1273
+ return node.type === 'Identifier' && node.name === 'type' || node.type === 'Keyword' && node.value === 'type';
1262
1274
  }
1263
1275
 
1264
1276
  function isCommaToken(node) {
@@ -6,6 +6,13 @@
6
6
  *
7
7
  * @flow strict-local
8
8
  * @format
9
+ * @generated
10
+ */
11
+
12
+ /*
13
+ * !!! GENERATED FILE !!!
14
+ *
15
+ * Any manual changes to this file will be overwritten. To regenerate run `yarn build`.
9
16
  */
10
17
 
11
18
  // lint directives to let us do some basic validation of generated files
@@ -56,6 +63,10 @@ export function isBigIntLiteralTypeAnnotation(
56
63
  return node.type === 'BigIntLiteralTypeAnnotation';
57
64
  }
58
65
 
66
+ export function isBigIntTypeAnnotation(node: ESNode | Token): boolean %checks {
67
+ return node.type === 'BigIntTypeAnnotation';
68
+ }
69
+
59
70
  export function isBinaryExpression(node: ESNode | Token): boolean %checks {
60
71
  return node.type === 'BinaryExpression';
61
72
  }
@@ -1024,78 +1035,78 @@ export function isYieldToken(node: ESNode | Token): boolean %checks {
1024
1035
 
1025
1036
  export function isAsKeyword(node: ESNode | Token): boolean %checks {
1026
1037
  return (
1027
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1028
- node.value === 'as'
1038
+ (node.type === 'Identifier' && node.name === 'as') ||
1039
+ (node.type === 'Keyword' && node.value === 'as')
1029
1040
  );
1030
1041
  }
1031
1042
 
1032
1043
  export function isAsyncKeyword(node: ESNode | Token): boolean %checks {
1033
1044
  return (
1034
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1035
- node.value === 'async'
1045
+ (node.type === 'Identifier' && node.name === 'async') ||
1046
+ (node.type === 'Keyword' && node.value === 'async')
1036
1047
  );
1037
1048
  }
1038
1049
 
1039
1050
  export function isAwaitKeyword(node: ESNode | Token): boolean %checks {
1040
1051
  return (
1041
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1042
- node.value === 'await'
1052
+ (node.type === 'Identifier' && node.name === 'await') ||
1053
+ (node.type === 'Keyword' && node.value === 'await')
1043
1054
  );
1044
1055
  }
1045
1056
 
1046
1057
  export function isDeclareKeyword(node: ESNode | Token): boolean %checks {
1047
1058
  return (
1048
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1049
- node.value === 'declare'
1059
+ (node.type === 'Identifier' && node.name === 'declare') ||
1060
+ (node.type === 'Keyword' && node.value === 'declare')
1050
1061
  );
1051
1062
  }
1052
1063
 
1053
1064
  export function isFromKeyword(node: ESNode | Token): boolean %checks {
1054
1065
  return (
1055
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1056
- node.value === 'from'
1066
+ (node.type === 'Identifier' && node.name === 'from') ||
1067
+ (node.type === 'Keyword' && node.value === 'from')
1057
1068
  );
1058
1069
  }
1059
1070
 
1060
1071
  export function isGetKeyword(node: ESNode | Token): boolean %checks {
1061
1072
  return (
1062
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1063
- node.value === 'get'
1073
+ (node.type === 'Identifier' && node.name === 'get') ||
1074
+ (node.type === 'Keyword' && node.value === 'get')
1064
1075
  );
1065
1076
  }
1066
1077
 
1067
1078
  export function isLetKeyword(node: ESNode | Token): boolean %checks {
1068
1079
  return (
1069
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1070
- node.value === 'let'
1080
+ (node.type === 'Identifier' && node.name === 'let') ||
1081
+ (node.type === 'Keyword' && node.value === 'let')
1071
1082
  );
1072
1083
  }
1073
1084
 
1074
1085
  export function isModuleKeyword(node: ESNode | Token): boolean %checks {
1075
1086
  return (
1076
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1077
- node.value === 'module'
1087
+ (node.type === 'Identifier' && node.name === 'module') ||
1088
+ (node.type === 'Keyword' && node.value === 'module')
1078
1089
  );
1079
1090
  }
1080
1091
 
1081
1092
  export function isOfKeyword(node: ESNode | Token): boolean %checks {
1082
1093
  return (
1083
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1084
- node.value === 'of'
1094
+ (node.type === 'Identifier' && node.name === 'of') ||
1095
+ (node.type === 'Keyword' && node.value === 'of')
1085
1096
  );
1086
1097
  }
1087
1098
 
1088
1099
  export function isSetKeyword(node: ESNode | Token): boolean %checks {
1089
1100
  return (
1090
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1091
- node.value === 'set'
1101
+ (node.type === 'Identifier' && node.name === 'set') ||
1102
+ (node.type === 'Keyword' && node.value === 'set')
1092
1103
  );
1093
1104
  }
1094
1105
 
1095
1106
  export function isTypeKeyword(node: ESNode | Token): boolean %checks {
1096
1107
  return (
1097
- (node.type === 'Identifier' || node.type === 'Keyword') &&
1098
- node.value === 'type'
1108
+ (node.type === 'Identifier' && node.name === 'type') ||
1109
+ (node.type === 'Keyword' && node.value === 'type')
1099
1110
  );
1100
1111
  }
1101
1112
 
@@ -29,7 +29,9 @@ var _exportNames = {
29
29
  isNullLiteral: true,
30
30
  isNumericLiteral: true,
31
31
  isRegExpLiteral: true,
32
- isStringLiteral: true
32
+ isStringLiteral: true,
33
+ isExpression: true,
34
+ isStatement: true
33
35
  };
34
36
  exports.isBigIntLiteral = isBigIntLiteral;
35
37
  exports.isBooleanLiteral = isBooleanLiteral;
@@ -37,6 +39,7 @@ exports.isClass = isClass;
37
39
  exports.isClassMember = isClassMember;
38
40
  exports.isClassMemberWithNonComputedName = isClassMemberWithNonComputedName;
39
41
  exports.isComment = isComment;
42
+ exports.isExpression = isExpression;
40
43
  exports.isFunction = isFunction;
41
44
  exports.isMemberExpressionWithNonComputedProperty = isMemberExpressionWithNonComputedProperty;
42
45
  exports.isMethodDefinitionWithNonComputedName = isMethodDefinitionWithNonComputedName;
@@ -47,6 +50,7 @@ exports.isObjectPropertyWithShorthand = isObjectPropertyWithShorthand;
47
50
  exports.isOptionalMemberExpressionWithNonComputedProperty = isOptionalMemberExpressionWithNonComputedProperty;
48
51
  exports.isPropertyDefinitionWithNonComputedName = isPropertyDefinitionWithNonComputedName;
49
52
  exports.isRegExpLiteral = isRegExpLiteral;
53
+ exports.isStatement = isStatement;
50
54
  exports.isStringLiteral = isStringLiteral;
51
55
 
52
56
  var _predicates = require("./generated/predicates");
@@ -124,4 +128,12 @@ function isRegExpLiteral(node) {
124
128
 
125
129
  function isStringLiteral(node) {
126
130
  return (0, _predicates.isLiteral)(node) && node.literalType === 'string';
131
+ }
132
+
133
+ function isExpression(node) {
134
+ return (0, _predicates.isThisExpression)(node) || (0, _predicates.isArrayExpression)(node) || (0, _predicates.isObjectExpression)(node) || (0, _predicates.isFunctionExpression)(node) || (0, _predicates.isArrowFunctionExpression)(node) || (0, _predicates.isYieldExpression)(node) || (0, _predicates.isLiteral)(node) || (0, _predicates.isUnaryExpression)(node) || (0, _predicates.isUpdateExpression)(node) || (0, _predicates.isBinaryExpression)(node) || (0, _predicates.isAssignmentExpression)(node) || (0, _predicates.isLogicalExpression)(node) || (0, _predicates.isMemberExpression)(node) || (0, _predicates.isConditionalExpression)(node) || (0, _predicates.isCallExpression)(node) || (0, _predicates.isNewExpression)(node) || (0, _predicates.isSequenceExpression)(node) || (0, _predicates.isTemplateLiteral)(node) || (0, _predicates.isTaggedTemplateExpression)(node) || (0, _predicates.isClassExpression)(node) || (0, _predicates.isMetaProperty)(node) || (0, _predicates.isIdentifier)(node) || (0, _predicates.isAwaitExpression)(node) || (0, _predicates.isImportExpression)(node) || (0, _predicates.isChainExpression)(node) || (0, _predicates.isTypeCastExpression)(node) || (0, _predicates.isJSXFragment)(node) || (0, _predicates.isJSXElement)(node);
135
+ }
136
+
137
+ function isStatement(node) {
138
+ return (0, _predicates.isBlockStatement)(node) || (0, _predicates.isBreakStatement)(node) || (0, _predicates.isClassDeclaration)(node) || (0, _predicates.isContinueStatement)(node) || (0, _predicates.isDebuggerStatement)(node) || (0, _predicates.isDeclareClass)(node) || (0, _predicates.isDeclareVariable)(node) || (0, _predicates.isDeclareFunction)(node) || (0, _predicates.isDeclareInterface)(node) || (0, _predicates.isDeclareModule)(node) || (0, _predicates.isDeclareOpaqueType)(node) || (0, _predicates.isDeclareTypeAlias)(node) || (0, _predicates.isDoWhileStatement)(node) || (0, _predicates.isEmptyStatement)(node) || (0, _predicates.isEnumDeclaration)(node) || (0, _predicates.isExpressionStatement)(node) || (0, _predicates.isForInStatement)(node) || (0, _predicates.isForOfStatement)(node) || (0, _predicates.isForStatement)(node) || (0, _predicates.isFunctionDeclaration)(node) || (0, _predicates.isIfStatement)(node) || (0, _predicates.isInterfaceDeclaration)(node) || (0, _predicates.isLabeledStatement)(node) || (0, _predicates.isOpaqueType)(node) || (0, _predicates.isReturnStatement)(node) || (0, _predicates.isSwitchStatement)(node) || (0, _predicates.isThrowStatement)(node) || (0, _predicates.isTryStatement)(node) || (0, _predicates.isTypeAlias)(node) || (0, _predicates.isVariableDeclaration)(node) || (0, _predicates.isWhileStatement)(node) || (0, _predicates.isWithStatement)(node);
127
139
  }
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @flow strict
7
+ * @flow strict-local
8
8
  * @format
9
9
  */
10
10
 
@@ -13,18 +13,71 @@
13
13
  import type {ESNode, Token} from './types';
14
14
 
15
15
  import {
16
+ isArrayExpression,
16
17
  isArrowFunctionExpression,
18
+ isAssignmentExpression,
19
+ isAwaitExpression,
20
+ isBinaryExpression,
17
21
  isBlockComment,
22
+ isBlockStatement,
23
+ isBreakStatement,
24
+ isCallExpression,
25
+ isChainExpression,
18
26
  isClassDeclaration,
19
27
  isClassExpression,
28
+ isConditionalExpression,
29
+ isContinueStatement,
30
+ isDebuggerStatement,
31
+ isDeclareClass,
32
+ isDeclareFunction,
33
+ isDeclareInterface,
34
+ isDeclareModule,
35
+ isDeclareOpaqueType,
36
+ isDeclareTypeAlias,
37
+ isDeclareVariable,
38
+ isDoWhileStatement,
39
+ isEmptyStatement,
40
+ isEnumDeclaration,
41
+ isExpressionStatement,
42
+ isForInStatement,
43
+ isForOfStatement,
44
+ isForStatement,
20
45
  isFunctionDeclaration,
21
46
  isFunctionExpression,
47
+ isIdentifier,
48
+ isIfStatement,
49
+ isImportExpression,
50
+ isInterfaceDeclaration,
51
+ isJSXElement,
52
+ isJSXFragment,
53
+ isLabeledStatement,
22
54
  isLineComment,
23
55
  isLiteral,
56
+ isLogicalExpression,
24
57
  isMemberExpression,
58
+ isMetaProperty,
25
59
  isMethodDefinition,
26
- isPropertyDefinition,
60
+ isNewExpression,
61
+ isObjectExpression,
62
+ isOpaqueType,
27
63
  isProperty,
64
+ isPropertyDefinition,
65
+ isReturnStatement,
66
+ isSequenceExpression,
67
+ isSwitchStatement,
68
+ isTaggedTemplateExpression,
69
+ isTemplateLiteral,
70
+ isThisExpression,
71
+ isThrowStatement,
72
+ isTryStatement,
73
+ isTypeAlias,
74
+ isTypeCastExpression,
75
+ isUnaryExpression,
76
+ isUpdateExpression,
77
+ isVariableDeclaration,
78
+ isWhileStatement,
79
+ isWithStatement,
80
+ isYieldExpression,
28
81
  } from './generated/predicates';
29
82
 
30
83
  export * from './generated/predicates';
@@ -112,3 +165,73 @@ export function isRegExpLiteral(node: ESNode): boolean %checks {
112
165
  export function isStringLiteral(node: ESNode): boolean %checks {
113
166
  return isLiteral(node) && node.literalType === 'string';
114
167
  }
168
+
169
+ export function isExpression(node: ESNode): boolean %checks {
170
+ return (
171
+ isThisExpression(node) ||
172
+ isArrayExpression(node) ||
173
+ isObjectExpression(node) ||
174
+ isFunctionExpression(node) ||
175
+ isArrowFunctionExpression(node) ||
176
+ isYieldExpression(node) ||
177
+ isLiteral(node) ||
178
+ isUnaryExpression(node) ||
179
+ isUpdateExpression(node) ||
180
+ isBinaryExpression(node) ||
181
+ isAssignmentExpression(node) ||
182
+ isLogicalExpression(node) ||
183
+ isMemberExpression(node) ||
184
+ isConditionalExpression(node) ||
185
+ isCallExpression(node) ||
186
+ isNewExpression(node) ||
187
+ isSequenceExpression(node) ||
188
+ isTemplateLiteral(node) ||
189
+ isTaggedTemplateExpression(node) ||
190
+ isClassExpression(node) ||
191
+ isMetaProperty(node) ||
192
+ isIdentifier(node) ||
193
+ isAwaitExpression(node) ||
194
+ isImportExpression(node) ||
195
+ isChainExpression(node) ||
196
+ isTypeCastExpression(node) ||
197
+ isJSXFragment(node) ||
198
+ isJSXElement(node)
199
+ );
200
+ }
201
+
202
+ export function isStatement(node: ESNode): boolean %checks {
203
+ return (
204
+ isBlockStatement(node) ||
205
+ isBreakStatement(node) ||
206
+ isClassDeclaration(node) ||
207
+ isContinueStatement(node) ||
208
+ isDebuggerStatement(node) ||
209
+ isDeclareClass(node) ||
210
+ isDeclareVariable(node) ||
211
+ isDeclareFunction(node) ||
212
+ isDeclareInterface(node) ||
213
+ isDeclareModule(node) ||
214
+ isDeclareOpaqueType(node) ||
215
+ isDeclareTypeAlias(node) ||
216
+ isDoWhileStatement(node) ||
217
+ isEmptyStatement(node) ||
218
+ isEnumDeclaration(node) ||
219
+ isExpressionStatement(node) ||
220
+ isForInStatement(node) ||
221
+ isForOfStatement(node) ||
222
+ isForStatement(node) ||
223
+ isFunctionDeclaration(node) ||
224
+ isIfStatement(node) ||
225
+ isInterfaceDeclaration(node) ||
226
+ isLabeledStatement(node) ||
227
+ isOpaqueType(node) ||
228
+ isReturnStatement(node) ||
229
+ isSwitchStatement(node) ||
230
+ isThrowStatement(node) ||
231
+ isTryStatement(node) ||
232
+ isTypeAlias(node) ||
233
+ isVariableDeclaration(node) ||
234
+ isWhileStatement(node) ||
235
+ isWithStatement(node)
236
+ );
237
+ }
@@ -38,7 +38,10 @@
38
38
 
39
39
  export type Range = [number, number];
40
40
 
41
- export interface BaseToken {
41
+ export interface ObjectWithLoc {
42
+ +loc: SourceLocation;
43
+ }
44
+ export interface BaseToken extends ObjectWithLoc {
42
45
  +loc: SourceLocation;
43
46
  +range: Range;
44
47
  }
@@ -106,7 +109,7 @@ export interface Position {
106
109
  }
107
110
 
108
111
  // note: this is only ever present on Program.interpreter, never in the body
109
- interface InterpreterDirective extends BaseNode {
112
+ export interface InterpreterDirective extends BaseNode {
110
113
  type: 'InterpreterDirective';
111
114
  value: string;
112
115
  }
@@ -226,6 +229,9 @@ export type Statement =
226
229
  | ClassDeclaration
227
230
  | ContinueStatement
228
231
  | DebuggerStatement
232
+ | DeclareClass
233
+ | DeclareVariable
234
+ | DeclareFunction
229
235
  | DeclareInterface
230
236
  | DeclareModule
231
237
  | DeclareOpaqueType
@@ -471,7 +477,7 @@ export interface ObjectPropertyWithShorthandStaticName
471
477
  // shorthand values *must* be identifiers (that look the same as the key)
472
478
  +value: Identifier;
473
479
  +kind: 'init';
474
- +method: boolean;
480
+ +method: false;
475
481
  +shorthand: true;
476
482
  }
477
483
  export interface ObjectPropertyWithComputedName extends ObjectPropertyBase {
@@ -850,7 +856,7 @@ interface BaseClass extends BaseNode {
850
856
  +body: ClassBody;
851
857
 
852
858
  +typeParameters: null | TypeParameterDeclaration;
853
- +superTypeParameters: null | TypeParameterDeclaration;
859
+ +superTypeParameters: null | TypeParameterInstantiation;
854
860
  +implements: $ReadOnlyArray<ClassImplements>;
855
861
  +decorators: $ReadOnlyArray<Decorator>;
856
862
  }
@@ -1024,13 +1030,30 @@ export type NamedDeclaration =
1024
1030
  | InterfaceDeclaration
1025
1031
  | EnumDeclaration;
1026
1032
 
1027
- export interface ExportNamedDeclaration extends BaseNode {
1033
+ interface ExportNamedDeclarationBase extends BaseNode {
1028
1034
  +type: 'ExportNamedDeclaration';
1029
1035
  +declaration?: NamedDeclaration | null;
1030
1036
  +specifiers: $ReadOnlyArray<ExportSpecifier>;
1031
- +source?: Literal | null;
1037
+ +source?: StringLiteral | null;
1032
1038
  +exportKind: 'value' | 'type';
1033
1039
  }
1040
+ export interface ExportNamedDeclarationWithSpecifiers
1041
+ extends ExportNamedDeclarationBase {
1042
+ +type: 'ExportNamedDeclaration';
1043
+ +declaration: null;
1044
+ +source: null;
1045
+ +specifiers: $ReadOnlyArray<ExportSpecifier>;
1046
+ }
1047
+ export interface ExportNamedDeclarationWithDeclaration
1048
+ extends ExportNamedDeclarationBase {
1049
+ +type: 'ExportNamedDeclaration';
1050
+ +declaration: NamedDeclaration;
1051
+ +source: null;
1052
+ +specifiers: [];
1053
+ }
1054
+ export type ExportNamedDeclaration =
1055
+ | ExportNamedDeclarationWithSpecifiers
1056
+ | ExportNamedDeclarationWithDeclaration;
1034
1057
 
1035
1058
  export interface ExportSpecifier extends BaseNode {
1036
1059
  +type: 'ExportSpecifier';
@@ -1045,7 +1068,7 @@ export interface ExportDefaultDeclaration extends BaseNode {
1045
1068
 
1046
1069
  export interface ExportAllDeclaration extends BaseNode {
1047
1070
  +type: 'ExportAllDeclaration';
1048
- +source: Literal;
1071
+ +source: StringLiteral;
1049
1072
  +exportKind: 'value' | 'type';
1050
1073
  +exported?: Identifier | null;
1051
1074
  }
@@ -1062,6 +1085,7 @@ export interface AwaitExpression extends BaseNode {
1062
1085
  export type TypeAnnotationType =
1063
1086
  | NumberTypeAnnotation
1064
1087
  | StringTypeAnnotation
1088
+ | BigIntTypeAnnotation
1065
1089
  | BooleanTypeAnnotation
1066
1090
  | NullLiteralTypeAnnotation
1067
1091
  | AnyTypeAnnotation
@@ -1125,6 +1149,9 @@ export interface NumberTypeAnnotation extends BaseNode {
1125
1149
  export interface StringTypeAnnotation extends BaseNode {
1126
1150
  +type: 'StringTypeAnnotation';
1127
1151
  }
1152
+ export interface BigIntTypeAnnotation extends BaseNode {
1153
+ +type: 'BigIntTypeAnnotation';
1154
+ }
1128
1155
  export interface BooleanTypeAnnotation extends BaseNode {
1129
1156
  +type: 'BooleanTypeAnnotation';
1130
1157
  }
@@ -1161,13 +1188,14 @@ export interface NumberLiteralTypeAnnotation extends BaseNode {
1161
1188
  }
1162
1189
  export interface BigIntLiteralTypeAnnotation extends BaseNode {
1163
1190
  +type: 'BigIntLiteralTypeAnnotation';
1164
- +value: null;
1191
+ +bigint: string;
1192
+ +value: null /* | bigint */;
1165
1193
  +raw: string;
1166
1194
  }
1167
1195
  export interface BooleanLiteralTypeAnnotation extends BaseNode {
1168
1196
  +type: 'BooleanLiteralTypeAnnotation';
1169
1197
  +value: boolean;
1170
- +raw: string;
1198
+ +raw: 'true' | 'false';
1171
1199
  }
1172
1200
  export interface ArrayTypeAnnotation extends BaseNode {
1173
1201
  +type: 'ArrayTypeAnnotation';
@@ -1196,7 +1224,7 @@ export interface TypeofTypeAnnotation extends BaseNode {
1196
1224
  }
1197
1225
  export interface TupleTypeAnnotation extends BaseNode {
1198
1226
  +type: 'TupleTypeAnnotation';
1199
- +types: TypeAnnotationType;
1227
+ +types: $ReadOnlyArray<TypeAnnotationType>;
1200
1228
  }
1201
1229
 
1202
1230
  // type T = { [[foo]]: number };
@@ -1230,7 +1258,7 @@ export interface FunctionTypeAnnotation extends BaseNode {
1230
1258
  +returnType: TypeAnnotationType;
1231
1259
  +rest: null | FunctionTypeParam;
1232
1260
  +typeParameters: null | TypeParameterDeclaration;
1233
- +this: TypeAnnotationType | null;
1261
+ +this: FunctionTypeParam | null;
1234
1262
  }
1235
1263
  export interface FunctionTypeParam extends BaseNode {
1236
1264
  +type: 'FunctionTypeParam';
@@ -1255,23 +1283,58 @@ export interface ObjectTypeAnnotation extends BaseNode {
1255
1283
  +callProperties: $ReadOnlyArray<ObjectTypeCallProperty>;
1256
1284
  +internalSlots: $ReadOnlyArray<ObjectTypeInternalSlot>;
1257
1285
  }
1258
- export interface ObjectTypeProperty extends BaseNode {
1286
+ interface ObjectTypePropertyBase extends BaseNode {
1259
1287
  +type: 'ObjectTypeProperty';
1260
- +key: Identifier;
1288
+ +key: Identifier | StringLiteral;
1261
1289
  +value: TypeAnnotationType;
1262
1290
  +method: boolean;
1263
1291
  +optional: boolean;
1264
- +static: false; // can't be static
1265
- +proto: false; // ???
1292
+ +static: boolean; // only applies to the "declare class" case
1293
+ +proto: boolean; // only applies to the "declare class" case
1294
+ +variance: Variance | null;
1295
+ +kind: 'init' | 'get' | 'set';
1296
+
1297
+ +parent: ObjectTypeAnnotation;
1298
+ }
1299
+ export interface ObjectTypeMethodSignature extends ObjectTypePropertyBase {
1300
+ +type: 'ObjectTypeProperty';
1301
+ +value: FunctionTypeAnnotation;
1302
+ +method: true;
1303
+ +optional: false;
1304
+ +variance: null;
1305
+ +kind: 'init';
1306
+
1307
+ +parent: ObjectTypeAnnotation;
1308
+ }
1309
+ export interface ObjectTypePropertySignature extends ObjectTypePropertyBase {
1310
+ +type: 'ObjectTypeProperty';
1311
+ +value: TypeAnnotationType;
1312
+ +method: false;
1313
+ +optional: boolean;
1266
1314
  +variance: Variance | null;
1267
1315
  +kind: 'init';
1268
1316
 
1269
1317
  +parent: ObjectTypeAnnotation;
1270
1318
  }
1319
+ export interface ObjectTypeAccessorSignature extends ObjectTypePropertyBase {
1320
+ +type: 'ObjectTypeProperty';
1321
+ +value: FunctionTypeAnnotation;
1322
+ +method: false;
1323
+ +optional: false;
1324
+ +variance: null;
1325
+ +kind: 'get' | 'set';
1326
+
1327
+ +parent: ObjectTypeAnnotation;
1328
+ }
1329
+ export type ObjectTypeProperty =
1330
+ | ObjectTypeMethodSignature
1331
+ | ObjectTypePropertySignature
1332
+ | ObjectTypeAccessorSignature;
1333
+
1271
1334
  export interface ObjectTypeCallProperty extends BaseNode {
1272
1335
  +type: 'ObjectTypeCallProperty';
1273
1336
  +value: FunctionTypeAnnotation;
1274
- +static: false; // can't be static
1337
+ +static: boolean; // can only be static when defined on a declare class
1275
1338
 
1276
1339
  +parent: ObjectTypeAnnotation;
1277
1340
  }
@@ -1280,7 +1343,7 @@ export interface ObjectTypeIndexer extends BaseNode {
1280
1343
  +id: null | Identifier;
1281
1344
  +key: TypeAnnotationType;
1282
1345
  +value: TypeAnnotationType;
1283
- +static: false; // can't be static
1346
+ +static: boolean; // can only be static when defined on a declare class
1284
1347
  +variance: null | Variance;
1285
1348
 
1286
1349
  +parent: ObjectTypeAnnotation;
@@ -1294,13 +1357,13 @@ export interface ObjectTypeSpreadProperty extends BaseNode {
1294
1357
 
1295
1358
  export interface IndexedAccessType extends BaseNode {
1296
1359
  +type: 'IndexedAccessType';
1297
- +objectType: TypeAnnotation;
1298
- +indexType: TypeAnnotation;
1360
+ +objectType: TypeAnnotationType;
1361
+ +indexType: TypeAnnotationType;
1299
1362
  }
1300
1363
  export interface OptionalIndexedAccessType extends BaseNode {
1301
1364
  +type: 'OptionalIndexedAccessType';
1302
- +objectType: TypeAnnotation;
1303
- +indexType: TypeAnnotation;
1365
+ +objectType: TypeAnnotationType;
1366
+ +indexType: TypeAnnotationType;
1304
1367
  +optional: boolean;
1305
1368
  }
1306
1369
 
@@ -1326,7 +1389,7 @@ export interface InterfaceDeclaration extends BaseInterfaceDeclaration {
1326
1389
  export interface InterfaceExtends extends BaseNode {
1327
1390
  +type: 'InterfaceExtends';
1328
1391
  +id: Identifier;
1329
- +typeParameters: null | TypeParameterDeclaration;
1392
+ +typeParameters: null | TypeParameterInstantiation;
1330
1393
 
1331
1394
  +parent: InterfaceDeclaration | DeclareInterface;
1332
1395
  }
@@ -1334,7 +1397,7 @@ export interface InterfaceExtends extends BaseNode {
1334
1397
  export interface ClassImplements extends BaseNode {
1335
1398
  +type: 'ClassImplements';
1336
1399
  +id: Identifier;
1337
- +typeParameters: null | TypeParameterDeclaration;
1400
+ +typeParameters: null | TypeParameterInstantiation;
1338
1401
 
1339
1402
  +parent: AClass | DeclareClass;
1340
1403
  }
@@ -1476,7 +1539,12 @@ export interface DeclareVariable extends BaseNode {
1476
1539
 
1477
1540
  export interface DeclareFunction extends BaseNode {
1478
1541
  +type: 'DeclareFunction';
1479
- +id: Identifier;
1542
+ // the function signature is stored as a type annotation on the ID
1543
+ +id: interface extends Identifier {
1544
+ +typeAnnotation: interface extends TypeAnnotation {
1545
+ +typeAnnotation: FunctionTypeAnnotation,
1546
+ },
1547
+ };
1480
1548
  +predicate: InferredPredicate | DeclaredPredicate | null;
1481
1549
  }
1482
1550
 
@@ -1505,19 +1573,49 @@ export interface DeclareExportAllDeclaration extends BaseNode {
1505
1573
  +source: StringLiteral;
1506
1574
  }
1507
1575
 
1508
- export interface DeclareExportDeclaration extends BaseNode {
1576
+ interface DeclareExportDeclarationBase extends BaseNode {
1509
1577
  +type: 'DeclareExportDeclaration';
1510
1578
  +specifiers: $ReadOnlyArray<ExportSpecifier>;
1579
+ +source: StringLiteral | null;
1580
+ +default: boolean;
1581
+ }
1582
+ export interface DeclareExportDefaultDeclaration
1583
+ extends DeclareExportDeclarationBase {
1584
+ +type: 'DeclareExportDeclaration';
1585
+ +declaration: DeclareClass | DeclareFunction | TypeAnnotationType;
1586
+ +default: true;
1587
+ // default cannot have a source
1588
+ +source: null;
1589
+ // default cannot have specifiers
1590
+ +specifiers: [];
1591
+ }
1592
+ export interface DeclareExportDeclarationNamedWithDeclaration
1593
+ extends DeclareExportDeclarationBase {
1594
+ +type: 'DeclareExportDeclaration';
1511
1595
  +declaration:
1512
- | TypeAlias
1513
1596
  | DeclareClass
1514
1597
  | DeclareFunction
1515
- | DeclareOpaqueType
1516
1598
  | DeclareInterface
1517
- | null;
1518
- +source: StringLiteral | null;
1519
- +default: boolean;
1599
+ | DeclareOpaqueType
1600
+ | DeclareVariable;
1601
+ +default: false;
1602
+ +source: null;
1603
+ // default cannot have specifiers and a declaration
1604
+ +specifiers: [];
1605
+ }
1606
+ export interface DeclareExportDeclarationNamedWithSpecifiers
1607
+ extends DeclareExportDeclarationBase {
1608
+ +type: 'DeclareExportDeclaration';
1609
+ // with a source you can't have a declaration
1610
+ +declaration: null;
1611
+ +default: false;
1612
+ +source: StringLiteral;
1613
+ +specifiers: $ReadOnlyArray<ExportSpecifier>;
1520
1614
  }
1615
+ export type DeclareExportDeclaration =
1616
+ | DeclareExportDefaultDeclaration
1617
+ | DeclareExportDeclarationNamedWithDeclaration
1618
+ | DeclareExportDeclarationNamedWithSpecifiers;
1521
1619
 
1522
1620
  export interface DeclareModuleExports extends BaseNode {
1523
1621
  +type: 'DeclareModuleExports';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-estree",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Flow types for the Flow-ESTree spec produced by the hermes parser",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",