hermes-estree 0.18.1 → 0.19.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.
@@ -61,6 +61,7 @@ import type {
61
61
  DeclareExportAllDeclaration,
62
62
  DeclareExportDeclaration,
63
63
  DeclareFunction,
64
+ DeclareHook,
64
65
  DeclareInterface,
65
66
  DeclareModule,
66
67
  DeclareModuleExports,
@@ -93,6 +94,8 @@ import type {
93
94
  FunctionTypeAnnotation,
94
95
  FunctionTypeParam,
95
96
  GenericTypeAnnotation,
97
+ HookDeclaration,
98
+ HookTypeAnnotation,
96
99
  Identifier,
97
100
  IfStatement,
98
101
  ImportAttribute,
@@ -502,6 +505,9 @@ interface DeclareFunction_With_id extends DeclareFunction {
502
505
  interface DeclareFunction_With_predicate extends DeclareFunction {
503
506
  +predicate: $NonMaybeType<DeclareFunction['predicate']>;
504
507
  }
508
+ interface DeclareHook_With_id extends DeclareHook {
509
+ +id: $NonMaybeType<DeclareHook['id']>;
510
+ }
505
511
  interface DeclareInterface_With_id extends DeclareInterface {
506
512
  +id: $NonMaybeType<DeclareInterface['id']>;
507
513
  }
@@ -774,6 +780,33 @@ interface GenericTypeAnnotation_With_typeParameters
774
780
  extends GenericTypeAnnotation {
775
781
  +typeParameters: $NonMaybeType<GenericTypeAnnotation['typeParameters']>;
776
782
  }
783
+ interface HookDeclaration_With_id extends HookDeclaration {
784
+ +id: $NonMaybeType<HookDeclaration['id']>;
785
+ }
786
+ interface HookDeclaration_With_params extends HookDeclaration {
787
+ +params: $NonMaybeType<HookDeclaration['params']>;
788
+ }
789
+ interface HookDeclaration_With_body extends HookDeclaration {
790
+ +body: $NonMaybeType<HookDeclaration['body']>;
791
+ }
792
+ interface HookDeclaration_With_typeParameters extends HookDeclaration {
793
+ +typeParameters: $NonMaybeType<HookDeclaration['typeParameters']>;
794
+ }
795
+ interface HookDeclaration_With_returnType extends HookDeclaration {
796
+ +returnType: $NonMaybeType<HookDeclaration['returnType']>;
797
+ }
798
+ interface HookTypeAnnotation_With_params extends HookTypeAnnotation {
799
+ +params: $NonMaybeType<HookTypeAnnotation['params']>;
800
+ }
801
+ interface HookTypeAnnotation_With_returnType extends HookTypeAnnotation {
802
+ +returnType: $NonMaybeType<HookTypeAnnotation['returnType']>;
803
+ }
804
+ interface HookTypeAnnotation_With_rest extends HookTypeAnnotation {
805
+ +rest: $NonMaybeType<HookTypeAnnotation['rest']>;
806
+ }
807
+ interface HookTypeAnnotation_With_typeParameters extends HookTypeAnnotation {
808
+ +typeParameters: $NonMaybeType<HookTypeAnnotation['typeParameters']>;
809
+ }
777
810
  interface Identifier_With_name extends Identifier {
778
811
  +name: $NonMaybeType<Identifier['name']>;
779
812
  }
@@ -1320,6 +1353,9 @@ interface TypeCastExpression_With_typeAnnotation extends TypeCastExpression {
1320
1353
  interface TypeofTypeAnnotation_With_argument extends TypeofTypeAnnotation {
1321
1354
  +argument: $NonMaybeType<TypeofTypeAnnotation['argument']>;
1322
1355
  }
1356
+ interface TypeofTypeAnnotation_With_typeArguments extends TypeofTypeAnnotation {
1357
+ +typeArguments: $NonMaybeType<TypeofTypeAnnotation['typeArguments']>;
1358
+ }
1323
1359
  interface TypeOperator_With_operator extends TypeOperator {
1324
1360
  +operator: $NonMaybeType<TypeOperator['operator']>;
1325
1361
  }
@@ -1442,6 +1478,7 @@ type DeclarationSpecialSelector =
1442
1478
  | ExportDefaultDeclaration
1443
1479
  | ExportNamedDeclaration
1444
1480
  | FunctionDeclaration
1481
+ | HookDeclaration
1445
1482
  | ImportDeclaration
1446
1483
  | InterfaceDeclaration
1447
1484
  | TypeParameterDeclaration
@@ -1736,6 +1773,8 @@ export type ESQueryNodeSelectorsWithoutFallback = {
1736
1773
  +'DeclareFunction[predicate]'?: (
1737
1774
  node: DeclareFunction_With_predicate,
1738
1775
  ) => void,
1776
+ +DeclareHook?: (node: DeclareHook) => void,
1777
+ +'DeclareHook[id]'?: (node: DeclareHook_With_id) => void,
1739
1778
  +DeclareInterface?: (node: DeclareInterface) => void,
1740
1779
  +'DeclareInterface[id]'?: (node: DeclareInterface_With_id) => void,
1741
1780
  +'DeclareInterface[typeParameters]'?: (
@@ -1940,6 +1979,27 @@ export type ESQueryNodeSelectorsWithoutFallback = {
1940
1979
  +'GenericTypeAnnotation[typeParameters]'?: (
1941
1980
  node: GenericTypeAnnotation_With_typeParameters,
1942
1981
  ) => void,
1982
+ +HookDeclaration?: (node: HookDeclaration) => void,
1983
+ +'HookDeclaration[id]'?: (node: HookDeclaration_With_id) => void,
1984
+ +'HookDeclaration[params]'?: (node: HookDeclaration_With_params) => void,
1985
+ +'HookDeclaration[body]'?: (node: HookDeclaration_With_body) => void,
1986
+ +'HookDeclaration[typeParameters]'?: (
1987
+ node: HookDeclaration_With_typeParameters,
1988
+ ) => void,
1989
+ +'HookDeclaration[returnType]'?: (
1990
+ node: HookDeclaration_With_returnType,
1991
+ ) => void,
1992
+ +HookTypeAnnotation?: (node: HookTypeAnnotation) => void,
1993
+ +'HookTypeAnnotation[params]'?: (
1994
+ node: HookTypeAnnotation_With_params,
1995
+ ) => void,
1996
+ +'HookTypeAnnotation[returnType]'?: (
1997
+ node: HookTypeAnnotation_With_returnType,
1998
+ ) => void,
1999
+ +'HookTypeAnnotation[rest]'?: (node: HookTypeAnnotation_With_rest) => void,
2000
+ +'HookTypeAnnotation[typeParameters]'?: (
2001
+ node: HookTypeAnnotation_With_typeParameters,
2002
+ ) => void,
1943
2003
  +Identifier?: (node: Identifier) => void,
1944
2004
  +'Identifier[name]'?: (node: Identifier_With_name) => void,
1945
2005
  +'Identifier[typeAnnotation]'?: (
@@ -2395,6 +2455,9 @@ export type ESQueryNodeSelectorsWithoutFallback = {
2395
2455
  +'TypeofTypeAnnotation[argument]'?: (
2396
2456
  node: TypeofTypeAnnotation_With_argument,
2397
2457
  ) => void,
2458
+ +'TypeofTypeAnnotation[typeArguments]'?: (
2459
+ node: TypeofTypeAnnotation_With_typeArguments,
2460
+ ) => void,
2398
2461
  +TypeOperator?: (node: TypeOperator) => void,
2399
2462
  +'TypeOperator[operator]'?: (node: TypeOperator_With_operator) => void,
2400
2463
  +'TypeOperator[typeAnnotation]'?: (
@@ -2751,6 +2814,8 @@ export type ESQueryNodeSelectorsWithoutFallback = {
2751
2814
  +'DeclareFunction[predicate]:exit'?: (
2752
2815
  node: DeclareFunction_With_predicate,
2753
2816
  ) => void,
2817
+ +'DeclareHook:exit'?: (node: DeclareHook) => void,
2818
+ +'DeclareHook[id]:exit'?: (node: DeclareHook_With_id) => void,
2754
2819
  +'DeclareInterface:exit'?: (node: DeclareInterface) => void,
2755
2820
  +'DeclareInterface[id]:exit'?: (node: DeclareInterface_With_id) => void,
2756
2821
  +'DeclareInterface[typeParameters]:exit'?: (
@@ -2969,6 +3034,29 @@ export type ESQueryNodeSelectorsWithoutFallback = {
2969
3034
  +'GenericTypeAnnotation[typeParameters]:exit'?: (
2970
3035
  node: GenericTypeAnnotation_With_typeParameters,
2971
3036
  ) => void,
3037
+ +'HookDeclaration:exit'?: (node: HookDeclaration) => void,
3038
+ +'HookDeclaration[id]:exit'?: (node: HookDeclaration_With_id) => void,
3039
+ +'HookDeclaration[params]:exit'?: (node: HookDeclaration_With_params) => void,
3040
+ +'HookDeclaration[body]:exit'?: (node: HookDeclaration_With_body) => void,
3041
+ +'HookDeclaration[typeParameters]:exit'?: (
3042
+ node: HookDeclaration_With_typeParameters,
3043
+ ) => void,
3044
+ +'HookDeclaration[returnType]:exit'?: (
3045
+ node: HookDeclaration_With_returnType,
3046
+ ) => void,
3047
+ +'HookTypeAnnotation:exit'?: (node: HookTypeAnnotation) => void,
3048
+ +'HookTypeAnnotation[params]:exit'?: (
3049
+ node: HookTypeAnnotation_With_params,
3050
+ ) => void,
3051
+ +'HookTypeAnnotation[returnType]:exit'?: (
3052
+ node: HookTypeAnnotation_With_returnType,
3053
+ ) => void,
3054
+ +'HookTypeAnnotation[rest]:exit'?: (
3055
+ node: HookTypeAnnotation_With_rest,
3056
+ ) => void,
3057
+ +'HookTypeAnnotation[typeParameters]:exit'?: (
3058
+ node: HookTypeAnnotation_With_typeParameters,
3059
+ ) => void,
2972
3060
  +'Identifier:exit'?: (node: Identifier) => void,
2973
3061
  +'Identifier[name]:exit'?: (node: Identifier_With_name) => void,
2974
3062
  +'Identifier[typeAnnotation]:exit'?: (
@@ -3468,6 +3556,9 @@ export type ESQueryNodeSelectorsWithoutFallback = {
3468
3556
  +'TypeofTypeAnnotation[argument]:exit'?: (
3469
3557
  node: TypeofTypeAnnotation_With_argument,
3470
3558
  ) => void,
3559
+ +'TypeofTypeAnnotation[typeArguments]:exit'?: (
3560
+ node: TypeofTypeAnnotation_With_typeArguments,
3561
+ ) => void,
3471
3562
  +'TypeOperator:exit'?: (node: TypeOperator) => void,
3472
3563
  +'TypeOperator[operator]:exit'?: (node: TypeOperator_With_operator) => void,
3473
3564
  +'TypeOperator[typeAnnotation]:exit'?: (
@@ -64,6 +64,7 @@ import type {
64
64
  DeclareExportAllDeclaration,
65
65
  DeclareExportDeclaration,
66
66
  DeclareFunction,
67
+ DeclareHook,
67
68
  DeclareInterface,
68
69
  DeclareModule,
69
70
  DeclareModuleExports,
@@ -96,6 +97,8 @@ import type {
96
97
  FunctionTypeAnnotation,
97
98
  FunctionTypeParam,
98
99
  GenericTypeAnnotation,
100
+ HookDeclaration,
101
+ HookTypeAnnotation,
99
102
  IfStatement,
100
103
  ImportAttribute,
101
104
  ImportDeclaration,
@@ -266,6 +269,7 @@ exports.isDeclareEnum = isDeclareEnum;
266
269
  exports.isDeclareExportAllDeclaration = isDeclareExportAllDeclaration;
267
270
  exports.isDeclareExportDeclaration = isDeclareExportDeclaration;
268
271
  exports.isDeclareFunction = isDeclareFunction;
272
+ exports.isDeclareHook = isDeclareHook;
269
273
  exports.isDeclareInterface = isDeclareInterface;
270
274
  exports.isDeclareKeyword = isDeclareKeyword;
271
275
  exports.isDeclareModule = isDeclareModule;
@@ -322,6 +326,8 @@ exports.isGenericTypeAnnotation = isGenericTypeAnnotation;
322
326
  exports.isGetKeyword = isGetKeyword;
323
327
  exports.isGreaterThanOrEqualToToken = isGreaterThanOrEqualToToken;
324
328
  exports.isGreaterThanToken = isGreaterThanToken;
329
+ exports.isHookDeclaration = isHookDeclaration;
330
+ exports.isHookTypeAnnotation = isHookTypeAnnotation;
325
331
  exports.isIdentifier = isIdentifier;
326
332
  exports.isIfStatement = isIfStatement;
327
333
  exports.isIfToken = isIfToken;
@@ -805,6 +811,14 @@ function isDeclareFunction(node
805
811
  return node.type === 'DeclareFunction';
806
812
  }
807
813
 
814
+ function isDeclareHook(node
815
+ /*: ESNode | Token */
816
+ )
817
+ /*: node is DeclareHook */
818
+ {
819
+ return node.type === 'DeclareHook';
820
+ }
821
+
808
822
  function isDeclareInterface(node
809
823
  /*: ESNode | Token */
810
824
  )
@@ -1061,6 +1075,22 @@ function isGenericTypeAnnotation(node
1061
1075
  return node.type === 'GenericTypeAnnotation';
1062
1076
  }
1063
1077
 
1078
+ function isHookDeclaration(node
1079
+ /*: ESNode | Token */
1080
+ )
1081
+ /*: node is HookDeclaration */
1082
+ {
1083
+ return node.type === 'HookDeclaration';
1084
+ }
1085
+
1086
+ function isHookTypeAnnotation(node
1087
+ /*: ESNode | Token */
1088
+ )
1089
+ /*: node is HookTypeAnnotation */
1090
+ {
1091
+ return node.type === 'HookTypeAnnotation';
1092
+ }
1093
+
1064
1094
  function isIfStatement(node
1065
1095
  /*: ESNode | Token */
1066
1096
  )
@@ -65,6 +65,7 @@ import type {
65
65
  DeclareExportAllDeclaration,
66
66
  DeclareExportDeclaration,
67
67
  DeclareFunction,
68
+ DeclareHook,
68
69
  DeclareInterface,
69
70
  DeclareModule,
70
71
  DeclareModuleExports,
@@ -97,6 +98,8 @@ import type {
97
98
  FunctionTypeAnnotation,
98
99
  FunctionTypeParam,
99
100
  GenericTypeAnnotation,
101
+ HookDeclaration,
102
+ HookTypeAnnotation,
100
103
  IfStatement,
101
104
  ImportAttribute,
102
105
  ImportDeclaration,
@@ -404,6 +407,11 @@ export function isDeclareFunction(node /*: ESNode | Token */) /*: node is Declar
404
407
  }
405
408
 
406
409
 
410
+ export function isDeclareHook(node /*: ESNode | Token */) /*: node is DeclareHook */ {
411
+ return node.type === 'DeclareHook';
412
+ }
413
+
414
+
407
415
  export function isDeclareInterface(node /*: ESNode | Token */) /*: node is DeclareInterface */ {
408
416
  return node.type === 'DeclareInterface';
409
417
  }
@@ -564,6 +572,16 @@ export function isGenericTypeAnnotation(node /*: ESNode | Token */) /*: node is
564
572
  }
565
573
 
566
574
 
575
+ export function isHookDeclaration(node /*: ESNode | Token */) /*: node is HookDeclaration */ {
576
+ return node.type === 'HookDeclaration';
577
+ }
578
+
579
+
580
+ export function isHookTypeAnnotation(node /*: ESNode | Token */) /*: node is HookTypeAnnotation */ {
581
+ return node.type === 'HookTypeAnnotation';
582
+ }
583
+
584
+
567
585
  export function isIfStatement(node /*: ESNode | Token */) /*: node is IfStatement */ {
568
586
  return node.type === 'IfStatement';
569
587
  }
@@ -62,77 +62,96 @@ Object.keys(_predicates).forEach(function (key) {
62
62
  exports[key] = _predicates[key];
63
63
  });
64
64
 
65
+ // $FlowFixMe[deprecated-type]
65
66
  function isClass(node) {
66
67
  return (0, _predicates.isClassDeclaration)(node) || (0, _predicates.isClassExpression)(node);
67
68
  }
68
69
 
69
- function isPropertyDefinitionWithNonComputedName(node) {
70
+ function isPropertyDefinitionWithNonComputedName(node // $FlowFixMe[deprecated-type]
71
+ ) {
70
72
  return (0, _predicates.isPropertyDefinition)(node) && node.computed === false;
71
- }
73
+ } // $FlowFixMe[deprecated-type]
74
+
72
75
 
73
76
  function isClassMember(node) {
74
77
  return (0, _predicates.isPropertyDefinition)(node) || (0, _predicates.isMethodDefinition)(node);
75
78
  }
76
79
 
77
- function isClassMemberWithNonComputedName(node) {
80
+ function isClassMemberWithNonComputedName(node // $FlowFixMe[deprecated-type]
81
+ ) {
78
82
  return isClassMember(node) && node.computed === false;
79
- }
83
+ } // $FlowFixMe[deprecated-type]
84
+
80
85
 
81
86
  function isComment(node) {
82
87
  return (0, _predicates.isBlockComment)(node) || (0, _predicates.isLineComment)(node);
83
- }
88
+ } // $FlowFixMe[deprecated-type]
89
+
84
90
 
85
91
  function isFunction(node) {
86
92
  return (0, _predicates.isArrowFunctionExpression)(node) || (0, _predicates.isFunctionDeclaration)(node) || (0, _predicates.isFunctionExpression)(node);
87
93
  }
88
94
 
89
- function isMethodDefinitionWithNonComputedName(node) {
95
+ function isMethodDefinitionWithNonComputedName(node // $FlowFixMe[deprecated-type]
96
+ ) {
90
97
  return (0, _predicates.isMethodDefinition)(node) && node.computed === false;
91
98
  }
92
99
 
93
- function isMemberExpressionWithNonComputedProperty(node) {
100
+ function isMemberExpressionWithNonComputedProperty(node // $FlowFixMe[deprecated-type]
101
+ ) {
94
102
  return (0, _predicates.isMemberExpression)(node) && node.computed === false;
95
103
  }
96
104
 
97
- function isOptionalMemberExpressionWithNonComputedProperty(node) {
105
+ function isOptionalMemberExpressionWithNonComputedProperty(node // $FlowFixMe[deprecated-type]
106
+ ) {
98
107
  return (0, _predicates.isMemberExpression)(node) && node.computed === false;
99
- }
108
+ } // $FlowFixMe[deprecated-type]
109
+
100
110
 
101
111
  function isObjectPropertyWithShorthand(node) {
102
112
  return (0, _predicates.isProperty)(node) && node.shorthand === true;
103
113
  }
104
114
 
105
- function isObjectPropertyWithNonComputedName(node) {
115
+ function isObjectPropertyWithNonComputedName(node // $FlowFixMe[deprecated-type]
116
+ ) {
106
117
  return (0, _predicates.isProperty)(node) && node.computed === false;
107
- }
118
+ } // $FlowFixMe[deprecated-type]
119
+
108
120
 
109
121
  function isBigIntLiteral(node) {
110
122
  return (0, _predicates.isLiteral)(node) && node.literalType === 'bigint';
111
- }
123
+ } // $FlowFixMe[deprecated-type]
124
+
112
125
 
113
126
  function isBooleanLiteral(node) {
114
127
  return (0, _predicates.isLiteral)(node) && node.literalType === 'boolean';
115
- }
128
+ } // $FlowFixMe[deprecated-type]
129
+
116
130
 
117
131
  function isNullLiteral(node) {
118
132
  return (0, _predicates.isLiteral)(node) && node.literalType === 'null';
119
- }
133
+ } // $FlowFixMe[deprecated-type]
134
+
120
135
 
121
136
  function isNumericLiteral(node) {
122
137
  return (0, _predicates.isLiteral)(node) && node.literalType === 'numeric';
123
- }
138
+ } // $FlowFixMe[deprecated-type]
139
+
124
140
 
125
141
  function isRegExpLiteral(node) {
126
142
  return (0, _predicates.isLiteral)(node) && node.literalType === 'regexp';
127
- }
143
+ } // $FlowFixMe[deprecated-type]
144
+
128
145
 
129
146
  function isStringLiteral(node) {
130
147
  return (0, _predicates.isLiteral)(node) && node.literalType === 'string';
131
- }
148
+ } // $FlowFixMe[deprecated-type]
149
+
132
150
 
133
151
  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
- }
152
+ 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.isAsExpression)(node) || (0, _predicates.isJSXFragment)(node) || (0, _predicates.isJSXElement)(node);
153
+ } // $FlowFixMe[deprecated-type]
154
+
136
155
 
137
156
  function isStatement(node) {
138
157
  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);
@@ -15,6 +15,7 @@ import type {ESNode, Token} from './types';
15
15
  import {
16
16
  isArrayExpression,
17
17
  isArrowFunctionExpression,
18
+ isAsExpression,
18
19
  isAssignmentExpression,
19
20
  isAwaitExpression,
20
21
  isBinaryExpression,
@@ -82,30 +83,36 @@ import {
82
83
 
83
84
  export * from './generated/predicates';
84
85
 
86
+ // $FlowFixMe[deprecated-type]
85
87
  export function isClass(node: ESNode): boolean %checks {
86
88
  return isClassDeclaration(node) || isClassExpression(node);
87
89
  }
88
90
 
89
91
  export function isPropertyDefinitionWithNonComputedName(
90
92
  node: ESNode,
93
+ // $FlowFixMe[deprecated-type]
91
94
  ): boolean %checks {
92
95
  return isPropertyDefinition(node) && node.computed === false;
93
96
  }
94
97
 
98
+ // $FlowFixMe[deprecated-type]
95
99
  export function isClassMember(node: ESNode): boolean %checks {
96
100
  return isPropertyDefinition(node) || isMethodDefinition(node);
97
101
  }
98
102
 
99
103
  export function isClassMemberWithNonComputedName(
100
104
  node: ESNode,
105
+ // $FlowFixMe[deprecated-type]
101
106
  ): boolean %checks {
102
107
  return isClassMember(node) && node.computed === false;
103
108
  }
104
109
 
110
+ // $FlowFixMe[deprecated-type]
105
111
  export function isComment(node: ESNode | Token): boolean %checks {
106
112
  return isBlockComment(node) || isLineComment(node);
107
113
  }
108
114
 
115
+ // $FlowFixMe[deprecated-type]
109
116
  export function isFunction(node: ESNode): boolean %checks {
110
117
  return (
111
118
  isArrowFunctionExpression(node) ||
@@ -116,56 +123,68 @@ export function isFunction(node: ESNode): boolean %checks {
116
123
 
117
124
  export function isMethodDefinitionWithNonComputedName(
118
125
  node: ESNode,
126
+ // $FlowFixMe[deprecated-type]
119
127
  ): boolean %checks {
120
128
  return isMethodDefinition(node) && node.computed === false;
121
129
  }
122
130
 
123
131
  export function isMemberExpressionWithNonComputedProperty(
124
132
  node: ESNode,
133
+ // $FlowFixMe[deprecated-type]
125
134
  ): boolean %checks {
126
135
  return isMemberExpression(node) && node.computed === false;
127
136
  }
128
137
 
129
138
  export function isOptionalMemberExpressionWithNonComputedProperty(
130
139
  node: ESNode,
140
+ // $FlowFixMe[deprecated-type]
131
141
  ): boolean %checks {
132
142
  return isMemberExpression(node) && node.computed === false;
133
143
  }
134
144
 
145
+ // $FlowFixMe[deprecated-type]
135
146
  export function isObjectPropertyWithShorthand(node: ESNode): boolean %checks {
136
147
  return isProperty(node) && node.shorthand === true;
137
148
  }
138
149
 
139
150
  export function isObjectPropertyWithNonComputedName(
140
151
  node: ESNode,
152
+ // $FlowFixMe[deprecated-type]
141
153
  ): boolean %checks {
142
154
  return isProperty(node) && node.computed === false;
143
155
  }
144
156
 
157
+ // $FlowFixMe[deprecated-type]
145
158
  export function isBigIntLiteral(node: ESNode): boolean %checks {
146
159
  return isLiteral(node) && node.literalType === 'bigint';
147
160
  }
148
161
 
162
+ // $FlowFixMe[deprecated-type]
149
163
  export function isBooleanLiteral(node: ESNode): boolean %checks {
150
164
  return isLiteral(node) && node.literalType === 'boolean';
151
165
  }
152
166
 
167
+ // $FlowFixMe[deprecated-type]
153
168
  export function isNullLiteral(node: ESNode): boolean %checks {
154
169
  return isLiteral(node) && node.literalType === 'null';
155
170
  }
156
171
 
172
+ // $FlowFixMe[deprecated-type]
157
173
  export function isNumericLiteral(node: ESNode): boolean %checks {
158
174
  return isLiteral(node) && node.literalType === 'numeric';
159
175
  }
160
176
 
177
+ // $FlowFixMe[deprecated-type]
161
178
  export function isRegExpLiteral(node: ESNode): boolean %checks {
162
179
  return isLiteral(node) && node.literalType === 'regexp';
163
180
  }
164
181
 
182
+ // $FlowFixMe[deprecated-type]
165
183
  export function isStringLiteral(node: ESNode): boolean %checks {
166
184
  return isLiteral(node) && node.literalType === 'string';
167
185
  }
168
186
 
187
+ // $FlowFixMe[deprecated-type]
169
188
  export function isExpression(node: ESNode): boolean %checks {
170
189
  return (
171
190
  isThisExpression(node) ||
@@ -194,11 +213,13 @@ export function isExpression(node: ESNode): boolean %checks {
194
213
  isImportExpression(node) ||
195
214
  isChainExpression(node) ||
196
215
  isTypeCastExpression(node) ||
216
+ isAsExpression(node) ||
197
217
  isJSXFragment(node) ||
198
218
  isJSXElement(node)
199
219
  );
200
220
  }
201
221
 
222
+ // $FlowFixMe[deprecated-type]
202
223
  export function isStatement(node: ESNode): boolean %checks {
203
224
  return (
204
225
  isBlockStatement(node) ||
@@ -189,6 +189,7 @@ export type ESNode =
189
189
  | TypeParameterInstantiation
190
190
  | ComponentDeclaration
191
191
  | ComponentParameter
192
+ | HookDeclaration
192
193
  | EnumDeclaration
193
194
  | EnumNumberBody
194
195
  | EnumStringBody
@@ -236,6 +237,7 @@ export type Statement =
236
237
  | DebuggerStatement
237
238
  | DeclareClass
238
239
  | DeclareComponent
240
+ | DeclareHook
239
241
  | DeclareVariable
240
242
  | DeclareEnum
241
243
  | DeclareFunction
@@ -251,6 +253,7 @@ export type Statement =
251
253
  | ForOfStatement
252
254
  | ForStatement
253
255
  | FunctionDeclaration
256
+ | HookDeclaration
254
257
  | IfStatement
255
258
  | InterfaceDeclaration
256
259
  | LabeledStatement
@@ -402,6 +405,15 @@ export interface ComponentDeclaration extends BaseNode {
402
405
  +typeParameters: null | TypeParameterDeclaration;
403
406
  }
404
407
 
408
+ export interface HookDeclaration extends BaseNode {
409
+ +type: 'HookDeclaration';
410
+ +id: Identifier;
411
+ +body: BlockStatement;
412
+ +params: $ReadOnlyArray<FunctionParameter>;
413
+ +returnType: null | TypeAnnotation;
414
+ +typeParameters: null | TypeParameterDeclaration;
415
+ }
416
+
405
417
  export interface FunctionDeclaration extends BaseFunction {
406
418
  +type: 'FunctionDeclaration';
407
419
  /** It is null when a function declaration is a part of the `export default function` statement */
@@ -1048,7 +1060,8 @@ export interface ImportNamespaceSpecifier extends BaseNode {
1048
1060
  export type DefaultDeclaration =
1049
1061
  | FunctionDeclaration
1050
1062
  | ClassDeclaration
1051
- | ComponentDeclaration;
1063
+ | ComponentDeclaration
1064
+ | HookDeclaration;
1052
1065
  export type NamedDeclaration =
1053
1066
  | DefaultDeclaration
1054
1067
  | VariableDeclaration
@@ -1144,6 +1157,7 @@ export type TypeAnnotationType =
1144
1157
  | TypeOperator
1145
1158
  | TypePredicate
1146
1159
  | FunctionTypeAnnotation
1160
+ | HookTypeAnnotation
1147
1161
  | ComponentTypeAnnotation
1148
1162
  | ObjectTypeAnnotation
1149
1163
  | IndexedAccessType
@@ -1262,6 +1276,7 @@ export interface QualifiedTypeofIdentifier extends BaseNode {
1262
1276
  export interface TypeofTypeAnnotation extends BaseNode {
1263
1277
  +type: 'TypeofTypeAnnotation';
1264
1278
  +argument: QualifiedTypeofIdentifier | Identifier;
1279
+ +typeArguments?: TypeParameterInstantiation;
1265
1280
  }
1266
1281
  export interface KeyofTypeAnnotation extends BaseNode {
1267
1282
  +type: 'KeyofTypeAnnotation';
@@ -1372,6 +1387,13 @@ export interface FunctionTypeParam extends BaseNode {
1372
1387
 
1373
1388
  +parent: FunctionTypeAnnotation;
1374
1389
  }
1390
+ export interface HookTypeAnnotation extends BaseNode {
1391
+ +type: 'HookTypeAnnotation';
1392
+ +params: $ReadOnlyArray<FunctionTypeParam>;
1393
+ +returnType: TypeAnnotationType;
1394
+ +rest: null | FunctionTypeParam;
1395
+ +typeParameters: null | TypeParameterDeclaration;
1396
+ }
1375
1397
 
1376
1398
  export interface ComponentTypeAnnotation extends BaseNode {
1377
1399
  +type: 'ComponentTypeAnnotation';
@@ -1653,6 +1675,7 @@ export interface EnumDefaultedMember extends BaseNode {
1653
1675
  export type DeclaredNode =
1654
1676
  | DeclareClass
1655
1677
  | DeclareComponent
1678
+ | DeclareHook
1656
1679
  | DeclareVariable
1657
1680
  | DeclareEnum
1658
1681
  | DeclareFunction
@@ -1684,6 +1707,16 @@ export interface DeclareComponent extends BaseNode {
1684
1707
  +rendersType: null | RendersType;
1685
1708
  }
1686
1709
 
1710
+ export interface DeclareHook extends BaseNode {
1711
+ +type: 'DeclareHook';
1712
+ // the hook signature is stored as a type annotation on the ID
1713
+ +id: interface extends Identifier {
1714
+ +typeAnnotation: interface extends TypeAnnotation {
1715
+ +typeAnnotation: HookTypeAnnotation,
1716
+ },
1717
+ };
1718
+ }
1719
+
1687
1720
  export interface DeclareVariable extends BaseNode {
1688
1721
  +type: 'DeclareVariable';
1689
1722
  +id: Identifier;
@@ -1745,6 +1778,7 @@ export interface DeclareExportDefaultDeclaration
1745
1778
  | DeclareClass
1746
1779
  | DeclareFunction
1747
1780
  | DeclareComponent
1781
+ | DeclareHook
1748
1782
  | TypeAnnotationType;
1749
1783
  +default: true;
1750
1784
  // default cannot have a source
@@ -1759,6 +1793,7 @@ export interface DeclareExportDeclarationNamedWithDeclaration
1759
1793
  | DeclareClass
1760
1794
  | DeclareFunction
1761
1795
  | DeclareComponent
1796
+ | DeclareHook
1762
1797
  | DeclareInterface
1763
1798
  | DeclareOpaqueType
1764
1799
  | DeclareVariable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-estree",
3
- "version": "0.18.1",
3
+ "version": "0.19.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",