hermes-estree 0.20.0 → 0.21.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.
- package/dist/generated/HermesESTreeSelectorTypes.js.flow +66 -5
- package/dist/generated/predicates.js +40 -2
- package/dist/generated/predicates.js.flow +28 -2
- package/dist/predicates.js +162 -70
- package/dist/predicates.js.flow +142 -196
- package/dist/types.js.flow +33 -3
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
// lint directives to let us do some basic validation of generated files
|
|
19
19
|
/* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
|
|
20
|
-
/* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray */
|
|
20
|
+
/* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray, $FlowFixMe */
|
|
21
21
|
|
|
22
22
|
'use strict';
|
|
23
23
|
|
|
@@ -28,6 +28,7 @@ import type {
|
|
|
28
28
|
ArrayPattern,
|
|
29
29
|
ArrayTypeAnnotation,
|
|
30
30
|
ArrowFunctionExpression,
|
|
31
|
+
AsConstExpression,
|
|
31
32
|
AsExpression,
|
|
32
33
|
AssignmentExpression,
|
|
33
34
|
AssignmentPattern,
|
|
@@ -72,6 +73,8 @@ import type {
|
|
|
72
73
|
DoWhileStatement,
|
|
73
74
|
EmptyStatement,
|
|
74
75
|
EmptyTypeAnnotation,
|
|
76
|
+
EnumBigIntBody,
|
|
77
|
+
EnumBigIntMember,
|
|
75
78
|
EnumBooleanBody,
|
|
76
79
|
EnumBooleanMember,
|
|
77
80
|
EnumDeclaration,
|
|
@@ -241,6 +244,9 @@ interface ArrowFunctionExpression_With_expression
|
|
|
241
244
|
interface ArrowFunctionExpression_With_async extends ArrowFunctionExpression {
|
|
242
245
|
+async: $NonMaybeType<ArrowFunctionExpression['async']>;
|
|
243
246
|
}
|
|
247
|
+
interface AsConstExpression_With_expression extends AsConstExpression {
|
|
248
|
+
+expression: $NonMaybeType<AsConstExpression['expression']>;
|
|
249
|
+
}
|
|
244
250
|
interface AsExpression_With_expression extends AsExpression {
|
|
245
251
|
+expression: $NonMaybeType<AsExpression['expression']>;
|
|
246
252
|
}
|
|
@@ -570,6 +576,21 @@ interface DoWhileStatement_With_body extends DoWhileStatement {
|
|
|
570
576
|
interface DoWhileStatement_With_test extends DoWhileStatement {
|
|
571
577
|
+test: $NonMaybeType<DoWhileStatement['test']>;
|
|
572
578
|
}
|
|
579
|
+
interface EnumBigIntBody_With_members extends EnumBigIntBody {
|
|
580
|
+
+members: $NonMaybeType<EnumBigIntBody['members']>;
|
|
581
|
+
}
|
|
582
|
+
interface EnumBigIntBody_With_explicitType extends EnumBigIntBody {
|
|
583
|
+
+explicitType: $NonMaybeType<EnumBigIntBody['explicitType']>;
|
|
584
|
+
}
|
|
585
|
+
interface EnumBigIntBody_With_hasUnknownMembers extends EnumBigIntBody {
|
|
586
|
+
+hasUnknownMembers: $NonMaybeType<EnumBigIntBody['hasUnknownMembers']>;
|
|
587
|
+
}
|
|
588
|
+
interface EnumBigIntMember_With_id extends EnumBigIntMember {
|
|
589
|
+
+id: $NonMaybeType<EnumBigIntMember['id']>;
|
|
590
|
+
}
|
|
591
|
+
interface EnumBigIntMember_With_init extends EnumBigIntMember {
|
|
592
|
+
+init: $NonMaybeType<EnumBigIntMember['init']>;
|
|
593
|
+
}
|
|
573
594
|
interface EnumBooleanBody_With_members extends EnumBooleanBody {
|
|
574
595
|
+members: $NonMaybeType<EnumBooleanBody['members']>;
|
|
575
596
|
}
|
|
@@ -1314,6 +1335,9 @@ interface TryStatement_With_finalizer extends TryStatement {
|
|
|
1314
1335
|
interface TupleTypeAnnotation_With_types extends TupleTypeAnnotation {
|
|
1315
1336
|
+types: $NonMaybeType<TupleTypeAnnotation['types']>;
|
|
1316
1337
|
}
|
|
1338
|
+
interface TupleTypeAnnotation_With_inexact extends TupleTypeAnnotation {
|
|
1339
|
+
+inexact: $NonMaybeType<TupleTypeAnnotation['inexact']>;
|
|
1340
|
+
}
|
|
1317
1341
|
interface TupleTypeLabeledElement_With_label extends TupleTypeLabeledElement {
|
|
1318
1342
|
+label: $NonMaybeType<TupleTypeLabeledElement['label']>;
|
|
1319
1343
|
}
|
|
@@ -1395,8 +1419,8 @@ interface TypePredicate_With_parameterName extends TypePredicate {
|
|
|
1395
1419
|
interface TypePredicate_With_typeAnnotation extends TypePredicate {
|
|
1396
1420
|
+typeAnnotation: $NonMaybeType<TypePredicate['typeAnnotation']>;
|
|
1397
1421
|
}
|
|
1398
|
-
interface
|
|
1399
|
-
+
|
|
1422
|
+
interface TypePredicate_With_kind extends TypePredicate {
|
|
1423
|
+
+kind: $NonMaybeType<TypePredicate['kind']>;
|
|
1400
1424
|
}
|
|
1401
1425
|
interface UnaryExpression_With_operator extends UnaryExpression {
|
|
1402
1426
|
+operator: $NonMaybeType<UnaryExpression['operator']>;
|
|
@@ -1493,6 +1517,7 @@ type ExpressionSpecialSelector =
|
|
|
1493
1517
|
| MetaProperty
|
|
1494
1518
|
| ArrayExpression
|
|
1495
1519
|
| ArrowFunctionExpression
|
|
1520
|
+
| AsConstExpression
|
|
1496
1521
|
| AsExpression
|
|
1497
1522
|
| AssignmentExpression
|
|
1498
1523
|
| AwaitExpression
|
|
@@ -1563,6 +1588,10 @@ export type ESQueryNodeSelectorsWithoutFallback = {
|
|
|
1563
1588
|
+'ArrowFunctionExpression[async]'?: (
|
|
1564
1589
|
node: ArrowFunctionExpression_With_async,
|
|
1565
1590
|
) => void,
|
|
1591
|
+
+AsConstExpression?: (node: AsConstExpression) => void,
|
|
1592
|
+
+'AsConstExpression[expression]'?: (
|
|
1593
|
+
node: AsConstExpression_With_expression,
|
|
1594
|
+
) => void,
|
|
1566
1595
|
+AsExpression?: (node: AsExpression) => void,
|
|
1567
1596
|
+'AsExpression[expression]'?: (node: AsExpression_With_expression) => void,
|
|
1568
1597
|
+'AsExpression[typeAnnotation]'?: (
|
|
@@ -1821,6 +1850,17 @@ export type ESQueryNodeSelectorsWithoutFallback = {
|
|
|
1821
1850
|
+'DoWhileStatement[test]'?: (node: DoWhileStatement_With_test) => void,
|
|
1822
1851
|
+EmptyStatement?: (node: EmptyStatement) => void,
|
|
1823
1852
|
+EmptyTypeAnnotation?: (node: EmptyTypeAnnotation) => void,
|
|
1853
|
+
+EnumBigIntBody?: (node: EnumBigIntBody) => void,
|
|
1854
|
+
+'EnumBigIntBody[members]'?: (node: EnumBigIntBody_With_members) => void,
|
|
1855
|
+
+'EnumBigIntBody[explicitType]'?: (
|
|
1856
|
+
node: EnumBigIntBody_With_explicitType,
|
|
1857
|
+
) => void,
|
|
1858
|
+
+'EnumBigIntBody[hasUnknownMembers]'?: (
|
|
1859
|
+
node: EnumBigIntBody_With_hasUnknownMembers,
|
|
1860
|
+
) => void,
|
|
1861
|
+
+EnumBigIntMember?: (node: EnumBigIntMember) => void,
|
|
1862
|
+
+'EnumBigIntMember[id]'?: (node: EnumBigIntMember_With_id) => void,
|
|
1863
|
+
+'EnumBigIntMember[init]'?: (node: EnumBigIntMember_With_init) => void,
|
|
1824
1864
|
+EnumBooleanBody?: (node: EnumBooleanBody) => void,
|
|
1825
1865
|
+'EnumBooleanBody[members]'?: (node: EnumBooleanBody_With_members) => void,
|
|
1826
1866
|
+'EnumBooleanBody[explicitType]'?: (
|
|
@@ -2422,6 +2462,9 @@ export type ESQueryNodeSelectorsWithoutFallback = {
|
|
|
2422
2462
|
+'TupleTypeAnnotation[types]'?: (
|
|
2423
2463
|
node: TupleTypeAnnotation_With_types,
|
|
2424
2464
|
) => void,
|
|
2465
|
+
+'TupleTypeAnnotation[inexact]'?: (
|
|
2466
|
+
node: TupleTypeAnnotation_With_inexact,
|
|
2467
|
+
) => void,
|
|
2425
2468
|
+TupleTypeLabeledElement?: (node: TupleTypeLabeledElement) => void,
|
|
2426
2469
|
+'TupleTypeLabeledElement[label]'?: (
|
|
2427
2470
|
node: TupleTypeLabeledElement_With_label,
|
|
@@ -2492,7 +2535,7 @@ export type ESQueryNodeSelectorsWithoutFallback = {
|
|
|
2492
2535
|
+'TypePredicate[typeAnnotation]'?: (
|
|
2493
2536
|
node: TypePredicate_With_typeAnnotation,
|
|
2494
2537
|
) => void,
|
|
2495
|
-
+'TypePredicate[
|
|
2538
|
+
+'TypePredicate[kind]'?: (node: TypePredicate_With_kind) => void,
|
|
2496
2539
|
+UnaryExpression?: (node: UnaryExpression) => void,
|
|
2497
2540
|
+'UnaryExpression[operator]'?: (node: UnaryExpression_With_operator) => void,
|
|
2498
2541
|
+'UnaryExpression[argument]'?: (node: UnaryExpression_With_argument) => void,
|
|
@@ -2578,6 +2621,10 @@ export type ESQueryNodeSelectorsWithoutFallback = {
|
|
|
2578
2621
|
+'ArrowFunctionExpression[async]:exit'?: (
|
|
2579
2622
|
node: ArrowFunctionExpression_With_async,
|
|
2580
2623
|
) => void,
|
|
2624
|
+
+'AsConstExpression:exit'?: (node: AsConstExpression) => void,
|
|
2625
|
+
+'AsConstExpression[expression]:exit'?: (
|
|
2626
|
+
node: AsConstExpression_With_expression,
|
|
2627
|
+
) => void,
|
|
2581
2628
|
+'AsExpression:exit'?: (node: AsExpression) => void,
|
|
2582
2629
|
+'AsExpression[expression]:exit'?: (
|
|
2583
2630
|
node: AsExpression_With_expression,
|
|
@@ -2866,6 +2913,17 @@ export type ESQueryNodeSelectorsWithoutFallback = {
|
|
|
2866
2913
|
+'DoWhileStatement[test]:exit'?: (node: DoWhileStatement_With_test) => void,
|
|
2867
2914
|
+'EmptyStatement:exit'?: (node: EmptyStatement) => void,
|
|
2868
2915
|
+'EmptyTypeAnnotation:exit'?: (node: EmptyTypeAnnotation) => void,
|
|
2916
|
+
+'EnumBigIntBody:exit'?: (node: EnumBigIntBody) => void,
|
|
2917
|
+
+'EnumBigIntBody[members]:exit'?: (node: EnumBigIntBody_With_members) => void,
|
|
2918
|
+
+'EnumBigIntBody[explicitType]:exit'?: (
|
|
2919
|
+
node: EnumBigIntBody_With_explicitType,
|
|
2920
|
+
) => void,
|
|
2921
|
+
+'EnumBigIntBody[hasUnknownMembers]:exit'?: (
|
|
2922
|
+
node: EnumBigIntBody_With_hasUnknownMembers,
|
|
2923
|
+
) => void,
|
|
2924
|
+
+'EnumBigIntMember:exit'?: (node: EnumBigIntMember) => void,
|
|
2925
|
+
+'EnumBigIntMember[id]:exit'?: (node: EnumBigIntMember_With_id) => void,
|
|
2926
|
+
+'EnumBigIntMember[init]:exit'?: (node: EnumBigIntMember_With_init) => void,
|
|
2869
2927
|
+'EnumBooleanBody:exit'?: (node: EnumBooleanBody) => void,
|
|
2870
2928
|
+'EnumBooleanBody[members]:exit'?: (
|
|
2871
2929
|
node: EnumBooleanBody_With_members,
|
|
@@ -3523,6 +3581,9 @@ export type ESQueryNodeSelectorsWithoutFallback = {
|
|
|
3523
3581
|
+'TupleTypeAnnotation[types]:exit'?: (
|
|
3524
3582
|
node: TupleTypeAnnotation_With_types,
|
|
3525
3583
|
) => void,
|
|
3584
|
+
+'TupleTypeAnnotation[inexact]:exit'?: (
|
|
3585
|
+
node: TupleTypeAnnotation_With_inexact,
|
|
3586
|
+
) => void,
|
|
3526
3587
|
+'TupleTypeLabeledElement:exit'?: (node: TupleTypeLabeledElement) => void,
|
|
3527
3588
|
+'TupleTypeLabeledElement[label]:exit'?: (
|
|
3528
3589
|
node: TupleTypeLabeledElement_With_label,
|
|
@@ -3597,7 +3658,7 @@ export type ESQueryNodeSelectorsWithoutFallback = {
|
|
|
3597
3658
|
+'TypePredicate[typeAnnotation]:exit'?: (
|
|
3598
3659
|
node: TypePredicate_With_typeAnnotation,
|
|
3599
3660
|
) => void,
|
|
3600
|
-
+'TypePredicate[
|
|
3661
|
+
+'TypePredicate[kind]:exit'?: (node: TypePredicate_With_kind) => void,
|
|
3601
3662
|
+'UnaryExpression:exit'?: (node: UnaryExpression) => void,
|
|
3602
3663
|
+'UnaryExpression[operator]:exit'?: (
|
|
3603
3664
|
node: UnaryExpression_With_operator,
|
|
@@ -17,12 +17,20 @@
|
|
|
17
17
|
|
|
18
18
|
/* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
|
|
19
19
|
|
|
20
|
-
/* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray */
|
|
20
|
+
/* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray, $FlowFixMe */
|
|
21
21
|
'use strict';
|
|
22
22
|
/*::
|
|
23
23
|
import type {
|
|
24
24
|
ESNode,
|
|
25
25
|
Token,
|
|
26
|
+
AFunction,
|
|
27
|
+
ClassMember,
|
|
28
|
+
BigIntLiteral,
|
|
29
|
+
BooleanLiteral,
|
|
30
|
+
NullLiteral,
|
|
31
|
+
NumericLiteral,
|
|
32
|
+
RegExpLiteral,
|
|
33
|
+
StringLiteral,
|
|
26
34
|
Identifier,
|
|
27
35
|
JSXIdentifier,
|
|
28
36
|
JSXText,
|
|
@@ -31,6 +39,7 @@ import type {
|
|
|
31
39
|
ArrayPattern,
|
|
32
40
|
ArrayTypeAnnotation,
|
|
33
41
|
ArrowFunctionExpression,
|
|
42
|
+
AsConstExpression,
|
|
34
43
|
AsExpression,
|
|
35
44
|
AssignmentExpression,
|
|
36
45
|
AssignmentPattern,
|
|
@@ -75,6 +84,8 @@ import type {
|
|
|
75
84
|
DoWhileStatement,
|
|
76
85
|
EmptyStatement,
|
|
77
86
|
EmptyTypeAnnotation,
|
|
87
|
+
EnumBigIntBody,
|
|
88
|
+
EnumBigIntMember,
|
|
78
89
|
EnumBooleanBody,
|
|
79
90
|
EnumBooleanMember,
|
|
80
91
|
EnumDeclaration,
|
|
@@ -198,7 +209,7 @@ import type {
|
|
|
198
209
|
LineComment,
|
|
199
210
|
BlockComment,
|
|
200
211
|
MostTokens,
|
|
201
|
-
} from '
|
|
212
|
+
} from '../types';
|
|
202
213
|
*/
|
|
203
214
|
|
|
204
215
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -209,6 +220,7 @@ exports.isArrayExpression = isArrayExpression;
|
|
|
209
220
|
exports.isArrayPattern = isArrayPattern;
|
|
210
221
|
exports.isArrayTypeAnnotation = isArrayTypeAnnotation;
|
|
211
222
|
exports.isArrowFunctionExpression = isArrowFunctionExpression;
|
|
223
|
+
exports.isAsConstExpression = isAsConstExpression;
|
|
212
224
|
exports.isAsExpression = isAsExpression;
|
|
213
225
|
exports.isAsKeyword = isAsKeyword;
|
|
214
226
|
exports.isAssignmentExpression = isAssignmentExpression;
|
|
@@ -291,6 +303,8 @@ exports.isDotToken = isDotToken;
|
|
|
291
303
|
exports.isElseToken = isElseToken;
|
|
292
304
|
exports.isEmptyStatement = isEmptyStatement;
|
|
293
305
|
exports.isEmptyTypeAnnotation = isEmptyTypeAnnotation;
|
|
306
|
+
exports.isEnumBigIntBody = isEnumBigIntBody;
|
|
307
|
+
exports.isEnumBigIntMember = isEnumBigIntMember;
|
|
294
308
|
exports.isEnumBooleanBody = isEnumBooleanBody;
|
|
295
309
|
exports.isEnumBooleanMember = isEnumBooleanMember;
|
|
296
310
|
exports.isEnumDeclaration = isEnumDeclaration;
|
|
@@ -549,6 +563,14 @@ function isArrowFunctionExpression(node
|
|
|
549
563
|
return node.type === 'ArrowFunctionExpression';
|
|
550
564
|
}
|
|
551
565
|
|
|
566
|
+
function isAsConstExpression(node
|
|
567
|
+
/*: ESNode | Token */
|
|
568
|
+
)
|
|
569
|
+
/*: node is AsConstExpression */
|
|
570
|
+
{
|
|
571
|
+
return node.type === 'AsConstExpression';
|
|
572
|
+
}
|
|
573
|
+
|
|
552
574
|
function isAsExpression(node
|
|
553
575
|
/*: ESNode | Token */
|
|
554
576
|
)
|
|
@@ -901,6 +923,22 @@ function isEmptyTypeAnnotation(node
|
|
|
901
923
|
return node.type === 'EmptyTypeAnnotation';
|
|
902
924
|
}
|
|
903
925
|
|
|
926
|
+
function isEnumBigIntBody(node
|
|
927
|
+
/*: ESNode | Token */
|
|
928
|
+
)
|
|
929
|
+
/*: node is EnumBigIntBody */
|
|
930
|
+
{
|
|
931
|
+
return node.type === 'EnumBigIntBody';
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function isEnumBigIntMember(node
|
|
935
|
+
/*: ESNode | Token */
|
|
936
|
+
)
|
|
937
|
+
/*: node is EnumBigIntMember */
|
|
938
|
+
{
|
|
939
|
+
return node.type === 'EnumBigIntMember';
|
|
940
|
+
}
|
|
941
|
+
|
|
904
942
|
function isEnumBooleanBody(node
|
|
905
943
|
/*: ESNode | Token */
|
|
906
944
|
)
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
// lint directives to let us do some basic validation of generated files
|
|
18
18
|
/* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
|
|
19
|
-
/* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray */
|
|
19
|
+
/* global $NonMaybeType, Partial, $ReadOnly, $ReadOnlyArray, $FlowFixMe */
|
|
20
20
|
|
|
21
21
|
'use strict';
|
|
22
22
|
|
|
@@ -24,6 +24,14 @@
|
|
|
24
24
|
import type {
|
|
25
25
|
ESNode,
|
|
26
26
|
Token,
|
|
27
|
+
AFunction,
|
|
28
|
+
ClassMember,
|
|
29
|
+
BigIntLiteral,
|
|
30
|
+
BooleanLiteral,
|
|
31
|
+
NullLiteral,
|
|
32
|
+
NumericLiteral,
|
|
33
|
+
RegExpLiteral,
|
|
34
|
+
StringLiteral,
|
|
27
35
|
Identifier,
|
|
28
36
|
JSXIdentifier,
|
|
29
37
|
JSXText,
|
|
@@ -32,6 +40,7 @@ import type {
|
|
|
32
40
|
ArrayPattern,
|
|
33
41
|
ArrayTypeAnnotation,
|
|
34
42
|
ArrowFunctionExpression,
|
|
43
|
+
AsConstExpression,
|
|
35
44
|
AsExpression,
|
|
36
45
|
AssignmentExpression,
|
|
37
46
|
AssignmentPattern,
|
|
@@ -76,6 +85,8 @@ import type {
|
|
|
76
85
|
DoWhileStatement,
|
|
77
86
|
EmptyStatement,
|
|
78
87
|
EmptyTypeAnnotation,
|
|
88
|
+
EnumBigIntBody,
|
|
89
|
+
EnumBigIntMember,
|
|
79
90
|
EnumBooleanBody,
|
|
80
91
|
EnumBooleanMember,
|
|
81
92
|
EnumDeclaration,
|
|
@@ -199,7 +210,7 @@ import type {
|
|
|
199
210
|
LineComment,
|
|
200
211
|
BlockComment,
|
|
201
212
|
MostTokens,
|
|
202
|
-
} from '
|
|
213
|
+
} from '../types';
|
|
203
214
|
*/
|
|
204
215
|
|
|
205
216
|
|
|
@@ -243,6 +254,11 @@ export function isArrowFunctionExpression(node /*: ESNode | Token */) /*: node i
|
|
|
243
254
|
}
|
|
244
255
|
|
|
245
256
|
|
|
257
|
+
export function isAsConstExpression(node /*: ESNode | Token */) /*: node is AsConstExpression */ {
|
|
258
|
+
return node.type === 'AsConstExpression';
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
|
|
246
262
|
export function isAsExpression(node /*: ESNode | Token */) /*: node is AsExpression */ {
|
|
247
263
|
return node.type === 'AsExpression';
|
|
248
264
|
}
|
|
@@ -463,6 +479,16 @@ export function isEmptyTypeAnnotation(node /*: ESNode | Token */) /*: node is Em
|
|
|
463
479
|
}
|
|
464
480
|
|
|
465
481
|
|
|
482
|
+
export function isEnumBigIntBody(node /*: ESNode | Token */) /*: node is EnumBigIntBody */ {
|
|
483
|
+
return node.type === 'EnumBigIntBody';
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
export function isEnumBigIntMember(node /*: ESNode | Token */) /*: node is EnumBigIntMember */ {
|
|
488
|
+
return node.type === 'EnumBigIntMember';
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
|
|
466
492
|
export function isEnumBooleanBody(node /*: ESNode | Token */) /*: node is EnumBooleanBody */ {
|
|
467
493
|
return node.type === 'EnumBooleanBody';
|
|
468
494
|
}
|
package/dist/predicates.js
CHANGED
|
@@ -5,9 +5,43 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*
|
|
8
|
-
* @format
|
|
9
8
|
*/
|
|
10
9
|
'use strict';
|
|
10
|
+
/*::
|
|
11
|
+
import type {
|
|
12
|
+
ESNode,
|
|
13
|
+
Token,
|
|
14
|
+
MostTokens,
|
|
15
|
+
BlockComment,
|
|
16
|
+
LineComment,
|
|
17
|
+
AFunction,
|
|
18
|
+
PropertyDefinition,
|
|
19
|
+
PropertyDefinitionWithNonComputedName,
|
|
20
|
+
MethodDefinition,
|
|
21
|
+
MethodDefinitionConstructor,
|
|
22
|
+
MethodDefinitionWithNonComputedName,
|
|
23
|
+
MemberExpression,
|
|
24
|
+
MemberExpressionWithNonComputedName,
|
|
25
|
+
ObjectPropertyWithShorthandStaticName,
|
|
26
|
+
ObjectPropertyWithNonShorthandStaticName,
|
|
27
|
+
DestructuringObjectPropertyWithShorthandStaticName,
|
|
28
|
+
DestructuringObjectPropertyWithNonShorthandStaticName,
|
|
29
|
+
ClassMember,
|
|
30
|
+
ClassDeclaration,
|
|
31
|
+
ClassExpression,
|
|
32
|
+
Literal,
|
|
33
|
+
BigIntLiteral,
|
|
34
|
+
BooleanLiteral,
|
|
35
|
+
NullLiteral,
|
|
36
|
+
NumericLiteral,
|
|
37
|
+
RegExpLiteral,
|
|
38
|
+
StringLiteral,
|
|
39
|
+
Identifier,
|
|
40
|
+
EnumDefaultedMember,
|
|
41
|
+
Expression,
|
|
42
|
+
Statement,
|
|
43
|
+
} from './types';
|
|
44
|
+
*/
|
|
11
45
|
|
|
12
46
|
Object.defineProperty(exports, "__esModule", {
|
|
13
47
|
value: true
|
|
@@ -62,97 +96,155 @@ Object.keys(_predicates).forEach(function (key) {
|
|
|
62
96
|
exports[key] = _predicates[key];
|
|
63
97
|
});
|
|
64
98
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
99
|
+
function isClass(node
|
|
100
|
+
/*: ESNode */
|
|
101
|
+
)
|
|
102
|
+
/*: node is (ClassDeclaration | ClassExpression) */
|
|
103
|
+
{
|
|
104
|
+
return node.type === 'ClassDeclaration' || node.type === 'ClassExpression';
|
|
68
105
|
}
|
|
69
106
|
|
|
70
|
-
function isPropertyDefinitionWithNonComputedName(node
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
function isClassMember(node) {
|
|
77
|
-
return (0, _predicates.isPropertyDefinition)(node) || (0, _predicates.isMethodDefinition)(node);
|
|
107
|
+
function isPropertyDefinitionWithNonComputedName(node
|
|
108
|
+
/*: ESNode */
|
|
109
|
+
)
|
|
110
|
+
/*: node is PropertyDefinitionWithNonComputedName */
|
|
111
|
+
{
|
|
112
|
+
return node.type === 'PropertyDefinition' && node.computed === false;
|
|
78
113
|
}
|
|
79
114
|
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
function isComment(node) {
|
|
87
|
-
return (0, _predicates.isBlockComment)(node) || (0, _predicates.isLineComment)(node);
|
|
88
|
-
} // $FlowFixMe[deprecated-type]
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
function isFunction(node) {
|
|
92
|
-
return (0, _predicates.isArrowFunctionExpression)(node) || (0, _predicates.isFunctionDeclaration)(node) || (0, _predicates.isFunctionExpression)(node);
|
|
115
|
+
function isClassMember(node
|
|
116
|
+
/*: ESNode */
|
|
117
|
+
)
|
|
118
|
+
/*: node is ClassMember */
|
|
119
|
+
{
|
|
120
|
+
return node.type === 'PropertyDefinition' || node.type === 'MethodDefinition';
|
|
93
121
|
}
|
|
94
122
|
|
|
95
|
-
function
|
|
96
|
-
|
|
97
|
-
|
|
123
|
+
function isClassMemberWithNonComputedName(node
|
|
124
|
+
/*: ESNode */
|
|
125
|
+
)
|
|
126
|
+
/*: node is (PropertyDefinitionWithNonComputedName | MethodDefinitionConstructor | MethodDefinitionWithNonComputedName) */
|
|
127
|
+
{
|
|
128
|
+
return (node.type === 'PropertyDefinition' || node.type === 'MethodDefinition') && node.computed === false;
|
|
98
129
|
}
|
|
99
130
|
|
|
100
|
-
function
|
|
101
|
-
|
|
102
|
-
|
|
131
|
+
function isComment(node
|
|
132
|
+
/*: ESNode | Token */
|
|
133
|
+
)
|
|
134
|
+
/*: node is (MostTokens | BlockComment | LineComment) */
|
|
135
|
+
{
|
|
136
|
+
return node.type === 'Block' || node.type === 'Line';
|
|
103
137
|
}
|
|
104
138
|
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
function isObjectPropertyWithShorthand(node) {
|
|
112
|
-
return (0, _predicates.isProperty)(node) && node.shorthand === true;
|
|
139
|
+
function isFunction(node
|
|
140
|
+
/*: ESNode */
|
|
141
|
+
)
|
|
142
|
+
/*: node is AFunction */
|
|
143
|
+
{
|
|
144
|
+
return node.type === 'ArrowFunctionExpression' || node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression';
|
|
113
145
|
}
|
|
114
146
|
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return (0, _predicates.isLiteral)(node) && node.literalType === 'bigint';
|
|
123
|
-
} // $FlowFixMe[deprecated-type]
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
function isBooleanLiteral(node) {
|
|
127
|
-
return (0, _predicates.isLiteral)(node) && node.literalType === 'boolean';
|
|
128
|
-
} // $FlowFixMe[deprecated-type]
|
|
147
|
+
function isMethodDefinitionWithNonComputedName(node
|
|
148
|
+
/*: ESNode */
|
|
149
|
+
)
|
|
150
|
+
/*: node is (MethodDefinitionConstructor | MethodDefinitionWithNonComputedName) */
|
|
151
|
+
{
|
|
152
|
+
return node.type === 'MethodDefinition' && node.computed === false;
|
|
153
|
+
}
|
|
129
154
|
|
|
155
|
+
function isMemberExpressionWithNonComputedProperty(node
|
|
156
|
+
/*: ESNode */
|
|
157
|
+
)
|
|
158
|
+
/*: node is MemberExpressionWithNonComputedName */
|
|
159
|
+
{
|
|
160
|
+
return node.type === 'MemberExpression' && node.computed === false;
|
|
161
|
+
}
|
|
130
162
|
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
163
|
+
function isOptionalMemberExpressionWithNonComputedProperty(node
|
|
164
|
+
/*: ESNode */
|
|
165
|
+
)
|
|
166
|
+
/*: node is MemberExpressionWithNonComputedName */
|
|
167
|
+
{
|
|
168
|
+
return node.type === 'MemberExpression' && node.computed === false;
|
|
169
|
+
}
|
|
134
170
|
|
|
171
|
+
function isObjectPropertyWithShorthand(node
|
|
172
|
+
/*: ESNode */
|
|
173
|
+
)
|
|
174
|
+
/*: node is (ObjectPropertyWithShorthandStaticName | DestructuringObjectPropertyWithShorthandStaticName) */
|
|
175
|
+
{
|
|
176
|
+
return node.type === 'Property' && node.shorthand === true;
|
|
177
|
+
}
|
|
135
178
|
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
|
|
179
|
+
function isObjectPropertyWithNonComputedName(node
|
|
180
|
+
/*: ESNode */
|
|
181
|
+
)
|
|
182
|
+
/*: node is (ObjectPropertyWithNonShorthandStaticName | ObjectPropertyWithShorthandStaticName | DestructuringObjectPropertyWithNonShorthandStaticName | DestructuringObjectPropertyWithShorthandStaticName) */
|
|
183
|
+
{
|
|
184
|
+
return node.type === 'Property' && node.computed === false;
|
|
185
|
+
}
|
|
139
186
|
|
|
187
|
+
function isBigIntLiteral(node
|
|
188
|
+
/*: ESNode */
|
|
189
|
+
)
|
|
190
|
+
/*: node is BigIntLiteral */
|
|
191
|
+
{
|
|
192
|
+
return node.type === 'Literal' && node.literalType === 'bigint';
|
|
193
|
+
}
|
|
140
194
|
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
|
|
195
|
+
function isBooleanLiteral(node
|
|
196
|
+
/*: ESNode */
|
|
197
|
+
)
|
|
198
|
+
/*: node is BooleanLiteral */
|
|
199
|
+
{
|
|
200
|
+
return node.type === 'Literal' && node.literalType === 'boolean';
|
|
201
|
+
}
|
|
144
202
|
|
|
203
|
+
function isNullLiteral(node
|
|
204
|
+
/*: ESNode */
|
|
205
|
+
)
|
|
206
|
+
/*: node is NullLiteral */
|
|
207
|
+
{
|
|
208
|
+
return node.type === 'Literal' && node.literalType === 'null';
|
|
209
|
+
}
|
|
145
210
|
|
|
146
|
-
function
|
|
147
|
-
|
|
148
|
-
|
|
211
|
+
function isNumericLiteral(node
|
|
212
|
+
/*: ESNode */
|
|
213
|
+
)
|
|
214
|
+
/*: node is NumericLiteral */
|
|
215
|
+
{
|
|
216
|
+
return node.type === 'Literal' && node.literalType === 'numeric';
|
|
217
|
+
}
|
|
149
218
|
|
|
219
|
+
function isRegExpLiteral(node
|
|
220
|
+
/*: ESNode */
|
|
221
|
+
)
|
|
222
|
+
/*: node is RegExpLiteral */
|
|
223
|
+
{
|
|
224
|
+
return node.type === 'Literal' && node.literalType === 'regexp';
|
|
225
|
+
}
|
|
150
226
|
|
|
151
|
-
function
|
|
152
|
-
|
|
153
|
-
|
|
227
|
+
function isStringLiteral(node
|
|
228
|
+
/*: ESNode */
|
|
229
|
+
)
|
|
230
|
+
/*: node is StringLiteral */
|
|
231
|
+
{
|
|
232
|
+
return node.type === 'Literal' && node.literalType === 'string';
|
|
233
|
+
}
|
|
154
234
|
|
|
235
|
+
function isExpression(node
|
|
236
|
+
/*: ESNode */
|
|
237
|
+
)
|
|
238
|
+
/*: node is Expression */
|
|
239
|
+
{
|
|
240
|
+
return node.type === 'ThisExpression' || node.type === 'ArrayExpression' || node.type === 'ObjectExpression' || // $FlowFixMe[incompatible-type]
|
|
241
|
+
node.type === 'ObjectExpression' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression' || node.type === 'YieldExpression' || node.type === 'Literal' || node.type === 'UnaryExpression' || node.type === 'UpdateExpression' || node.type === 'BinaryExpression' || node.type === 'AssignmentExpression' || node.type === 'LogicalExpression' || node.type === 'MemberExpression' || node.type === 'ConditionalExpression' || node.type === 'CallExpression' || node.type === 'NewExpression' || node.type === 'SequenceExpression' || node.type === 'TemplateLiteral' || node.type === 'TaggedTemplateExpression' || node.type === 'ClassExpression' || node.type === 'MetaProperty' || node.type === 'Identifier' || node.type === 'AwaitExpression' || node.type === 'ImportExpression' || node.type === 'ChainExpression' || node.type === 'TypeCastExpression' || node.type === 'AsExpression' || node.type === 'AsConstExpression' || node.type === 'JSXFragment' || node.type === 'JSXElement';
|
|
242
|
+
}
|
|
155
243
|
|
|
156
|
-
function isStatement(node
|
|
157
|
-
|
|
244
|
+
function isStatement(node
|
|
245
|
+
/*: ESNode */
|
|
246
|
+
)
|
|
247
|
+
/*: node is Statement */
|
|
248
|
+
{
|
|
249
|
+
return node.type === 'BlockStatement' || node.type === 'BreakStatement' || node.type === 'ClassDeclaration' || node.type === 'ContinueStatement' || node.type === 'DebuggerStatement' || node.type === 'DeclareClass' || node.type === 'DeclareVariable' || node.type === 'DeclareFunction' || node.type === 'DeclareInterface' || node.type === 'DeclareModule' || node.type === 'DeclareOpaqueType' || node.type === 'DeclareTypeAlias' || node.type === 'DoWhileStatement' || node.type === 'EmptyStatement' || node.type === 'EnumDeclaration' || node.type === 'ExpressionStatement' || node.type === 'ForInStatement' || node.type === 'ForOfStatement' || node.type === 'ForStatement' || node.type === 'FunctionDeclaration' || node.type === 'IfStatement' || node.type === 'InterfaceDeclaration' || node.type === 'LabeledStatement' || node.type === 'OpaqueType' || node.type === 'ReturnStatement' || node.type === 'SwitchStatement' || node.type === 'ThrowStatement' || node.type === 'TryStatement' || node.type === 'TypeAlias' || node.type === 'VariableDeclaration' || node.type === 'WhileStatement' || node.type === 'WithStatement';
|
|
158
250
|
}
|
package/dist/predicates.js.flow
CHANGED
|
@@ -5,254 +5,200 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
* @flow strict-local
|
|
8
|
-
* @format
|
|
9
8
|
*/
|
|
10
9
|
|
|
11
10
|
'use strict';
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
isIdentifier,
|
|
49
|
-
isIfStatement,
|
|
50
|
-
isImportExpression,
|
|
51
|
-
isInterfaceDeclaration,
|
|
52
|
-
isJSXElement,
|
|
53
|
-
isJSXFragment,
|
|
54
|
-
isLabeledStatement,
|
|
55
|
-
isLineComment,
|
|
56
|
-
isLiteral,
|
|
57
|
-
isLogicalExpression,
|
|
58
|
-
isMemberExpression,
|
|
59
|
-
isMetaProperty,
|
|
60
|
-
isMethodDefinition,
|
|
61
|
-
isNewExpression,
|
|
62
|
-
isObjectExpression,
|
|
63
|
-
isOpaqueType,
|
|
64
|
-
isProperty,
|
|
65
|
-
isPropertyDefinition,
|
|
66
|
-
isReturnStatement,
|
|
67
|
-
isSequenceExpression,
|
|
68
|
-
isSwitchStatement,
|
|
69
|
-
isTaggedTemplateExpression,
|
|
70
|
-
isTemplateLiteral,
|
|
71
|
-
isThisExpression,
|
|
72
|
-
isThrowStatement,
|
|
73
|
-
isTryStatement,
|
|
74
|
-
isTypeAlias,
|
|
75
|
-
isTypeCastExpression,
|
|
76
|
-
isUnaryExpression,
|
|
77
|
-
isUpdateExpression,
|
|
78
|
-
isVariableDeclaration,
|
|
79
|
-
isWhileStatement,
|
|
80
|
-
isWithStatement,
|
|
81
|
-
isYieldExpression,
|
|
82
|
-
} from './generated/predicates';
|
|
12
|
+
/*::
|
|
13
|
+
import type {
|
|
14
|
+
ESNode,
|
|
15
|
+
Token,
|
|
16
|
+
MostTokens,
|
|
17
|
+
BlockComment,
|
|
18
|
+
LineComment,
|
|
19
|
+
AFunction,
|
|
20
|
+
PropertyDefinition,
|
|
21
|
+
PropertyDefinitionWithNonComputedName,
|
|
22
|
+
MethodDefinition,
|
|
23
|
+
MethodDefinitionConstructor,
|
|
24
|
+
MethodDefinitionWithNonComputedName,
|
|
25
|
+
MemberExpression,
|
|
26
|
+
MemberExpressionWithNonComputedName,
|
|
27
|
+
ObjectPropertyWithShorthandStaticName,
|
|
28
|
+
ObjectPropertyWithNonShorthandStaticName,
|
|
29
|
+
DestructuringObjectPropertyWithShorthandStaticName,
|
|
30
|
+
DestructuringObjectPropertyWithNonShorthandStaticName,
|
|
31
|
+
ClassMember,
|
|
32
|
+
ClassDeclaration,
|
|
33
|
+
ClassExpression,
|
|
34
|
+
Literal,
|
|
35
|
+
BigIntLiteral,
|
|
36
|
+
BooleanLiteral,
|
|
37
|
+
NullLiteral,
|
|
38
|
+
NumericLiteral,
|
|
39
|
+
RegExpLiteral,
|
|
40
|
+
StringLiteral,
|
|
41
|
+
Identifier,
|
|
42
|
+
EnumDefaultedMember,
|
|
43
|
+
Expression,
|
|
44
|
+
Statement,
|
|
45
|
+
} from './types';
|
|
46
|
+
*/
|
|
83
47
|
|
|
84
48
|
export * from './generated/predicates';
|
|
85
49
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return isClassDeclaration(node) || isClassExpression(node);
|
|
50
|
+
export function isClass(node /*: ESNode */) /*: node is (ClassDeclaration | ClassExpression) */ {
|
|
51
|
+
return node.type === 'ClassDeclaration' || node.type === 'ClassExpression';
|
|
89
52
|
}
|
|
90
53
|
|
|
91
54
|
export function isPropertyDefinitionWithNonComputedName(
|
|
92
|
-
node
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return isPropertyDefinition(node) && node.computed === false;
|
|
55
|
+
node /*: ESNode */,
|
|
56
|
+
) /*: node is PropertyDefinitionWithNonComputedName */ {
|
|
57
|
+
return node.type === 'PropertyDefinition' && node.computed === false;
|
|
96
58
|
}
|
|
97
59
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return isPropertyDefinition(node) || isMethodDefinition(node);
|
|
60
|
+
export function isClassMember(node /*: ESNode */) /*: node is ClassMember */ {
|
|
61
|
+
return node.type === 'PropertyDefinition' || node.type === 'MethodDefinition';
|
|
101
62
|
}
|
|
102
63
|
|
|
103
64
|
export function isClassMemberWithNonComputedName(
|
|
104
|
-
node
|
|
105
|
-
|
|
106
|
-
)
|
|
107
|
-
return isClassMember(node) && node.computed === false;
|
|
65
|
+
node /*: ESNode */,
|
|
66
|
+
) /*: node is (PropertyDefinitionWithNonComputedName | MethodDefinitionConstructor | MethodDefinitionWithNonComputedName) */ {
|
|
67
|
+
return (node.type === 'PropertyDefinition' || node.type === 'MethodDefinition') && node.computed === false;
|
|
108
68
|
}
|
|
109
69
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return isBlockComment(node) || isLineComment(node);
|
|
70
|
+
export function isComment(node /*: ESNode | Token */) /*: node is (MostTokens | BlockComment | LineComment) */ {
|
|
71
|
+
return node.type === 'Block' || node.type === 'Line';
|
|
113
72
|
}
|
|
114
73
|
|
|
115
|
-
|
|
116
|
-
export function isFunction(node: ESNode): boolean %checks {
|
|
74
|
+
export function isFunction(node /*: ESNode */) /*: node is AFunction */ {
|
|
117
75
|
return (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
76
|
+
node.type === 'ArrowFunctionExpression' ||
|
|
77
|
+
node.type === 'FunctionDeclaration' ||
|
|
78
|
+
node.type === 'FunctionExpression'
|
|
121
79
|
);
|
|
122
80
|
}
|
|
123
81
|
|
|
124
82
|
export function isMethodDefinitionWithNonComputedName(
|
|
125
|
-
node
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return isMethodDefinition(node) && node.computed === false;
|
|
83
|
+
node /*: ESNode */,
|
|
84
|
+
) /*: node is (MethodDefinitionConstructor | MethodDefinitionWithNonComputedName) */ {
|
|
85
|
+
return node.type === 'MethodDefinition' && node.computed === false;
|
|
129
86
|
}
|
|
130
87
|
|
|
131
88
|
export function isMemberExpressionWithNonComputedProperty(
|
|
132
|
-
node
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return isMemberExpression(node) && node.computed === false;
|
|
89
|
+
node /*: ESNode */,
|
|
90
|
+
) /*: node is MemberExpressionWithNonComputedName */ {
|
|
91
|
+
return node.type === 'MemberExpression' && node.computed === false;
|
|
136
92
|
}
|
|
137
93
|
|
|
138
94
|
export function isOptionalMemberExpressionWithNonComputedProperty(
|
|
139
|
-
node
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return isMemberExpression(node) && node.computed === false;
|
|
95
|
+
node /*: ESNode */,
|
|
96
|
+
) /*: node is MemberExpressionWithNonComputedName */ {
|
|
97
|
+
return node.type === 'MemberExpression' && node.computed === false;
|
|
143
98
|
}
|
|
144
99
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return isProperty(node) && node.shorthand === true;
|
|
100
|
+
export function isObjectPropertyWithShorthand(node /*: ESNode */) /*: node is (ObjectPropertyWithShorthandStaticName | DestructuringObjectPropertyWithShorthandStaticName) */ {
|
|
101
|
+
return node.type === 'Property' && node.shorthand === true;
|
|
148
102
|
}
|
|
149
103
|
|
|
150
|
-
export function isObjectPropertyWithNonComputedName(
|
|
151
|
-
node
|
|
152
|
-
// $FlowFixMe[deprecated-type]
|
|
153
|
-
): boolean %checks {
|
|
154
|
-
return isProperty(node) && node.computed === false;
|
|
104
|
+
export function isObjectPropertyWithNonComputedName(node /*: ESNode */) /*: node is (ObjectPropertyWithNonShorthandStaticName | ObjectPropertyWithShorthandStaticName | DestructuringObjectPropertyWithNonShorthandStaticName | DestructuringObjectPropertyWithShorthandStaticName) */ {
|
|
105
|
+
return node.type === 'Property' && node.computed === false;
|
|
155
106
|
}
|
|
156
107
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return isLiteral(node) && node.literalType === 'bigint';
|
|
108
|
+
export function isBigIntLiteral(node /*: ESNode */) /*: node is BigIntLiteral */ {
|
|
109
|
+
return node.type === 'Literal' && node.literalType === 'bigint';
|
|
160
110
|
}
|
|
161
111
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return isLiteral(node) && node.literalType === 'boolean';
|
|
112
|
+
export function isBooleanLiteral(node /*: ESNode */) /*: node is BooleanLiteral */ {
|
|
113
|
+
return node.type === 'Literal' && node.literalType === 'boolean';
|
|
165
114
|
}
|
|
166
115
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return isLiteral(node) && node.literalType === 'null';
|
|
116
|
+
export function isNullLiteral(node /*: ESNode */) /*: node is NullLiteral */ {
|
|
117
|
+
return node.type === 'Literal' && node.literalType === 'null';
|
|
170
118
|
}
|
|
171
119
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return isLiteral(node) && node.literalType === 'numeric';
|
|
120
|
+
export function isNumericLiteral(node /*: ESNode */) /*: node is NumericLiteral */ {
|
|
121
|
+
return node.type === 'Literal' && node.literalType === 'numeric';
|
|
175
122
|
}
|
|
176
123
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return isLiteral(node) && node.literalType === 'regexp';
|
|
124
|
+
export function isRegExpLiteral(node /*: ESNode */) /*: node is RegExpLiteral */ {
|
|
125
|
+
return node.type === 'Literal' && node.literalType === 'regexp';
|
|
180
126
|
}
|
|
181
127
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return isLiteral(node) && node.literalType === 'string';
|
|
128
|
+
export function isStringLiteral(node /*: ESNode */) /*: node is StringLiteral */ {
|
|
129
|
+
return node.type === 'Literal' && node.literalType === 'string';
|
|
185
130
|
}
|
|
186
131
|
|
|
187
|
-
|
|
188
|
-
export function isExpression(node: ESNode): boolean %checks {
|
|
132
|
+
export function isExpression(node /*: ESNode */) /*: node is Expression */ {
|
|
189
133
|
return (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
134
|
+
node.type === 'ThisExpression' ||
|
|
135
|
+
node.type === 'ArrayExpression' ||
|
|
136
|
+
node.type === 'ObjectExpression' ||
|
|
137
|
+
// $FlowFixMe[incompatible-type]
|
|
138
|
+
node.type === 'ObjectExpression' ||
|
|
139
|
+
node.type === 'FunctionExpression' ||
|
|
140
|
+
node.type === 'ArrowFunctionExpression' ||
|
|
141
|
+
node.type === 'YieldExpression' ||
|
|
142
|
+
node.type === 'Literal' ||
|
|
143
|
+
node.type === 'UnaryExpression' ||
|
|
144
|
+
node.type === 'UpdateExpression' ||
|
|
145
|
+
node.type === 'BinaryExpression' ||
|
|
146
|
+
node.type === 'AssignmentExpression' ||
|
|
147
|
+
node.type === 'LogicalExpression' ||
|
|
148
|
+
node.type === 'MemberExpression' ||
|
|
149
|
+
node.type === 'ConditionalExpression' ||
|
|
150
|
+
node.type === 'CallExpression' ||
|
|
151
|
+
node.type === 'NewExpression' ||
|
|
152
|
+
node.type === 'SequenceExpression' ||
|
|
153
|
+
node.type === 'TemplateLiteral' ||
|
|
154
|
+
node.type === 'TaggedTemplateExpression' ||
|
|
155
|
+
node.type === 'ClassExpression' ||
|
|
156
|
+
node.type === 'MetaProperty' ||
|
|
157
|
+
node.type === 'Identifier' ||
|
|
158
|
+
node.type === 'AwaitExpression' ||
|
|
159
|
+
node.type === 'ImportExpression' ||
|
|
160
|
+
node.type === 'ChainExpression' ||
|
|
161
|
+
node.type === 'TypeCastExpression' ||
|
|
162
|
+
node.type === 'AsExpression' ||
|
|
163
|
+
node.type === 'AsConstExpression' ||
|
|
164
|
+
node.type === 'JSXFragment' ||
|
|
165
|
+
node.type === 'JSXElement'
|
|
219
166
|
);
|
|
220
167
|
}
|
|
221
168
|
|
|
222
|
-
|
|
223
|
-
export function isStatement(node: ESNode): boolean %checks {
|
|
169
|
+
export function isStatement(node /*: ESNode */) /*: node is Statement */ {
|
|
224
170
|
return (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
171
|
+
node.type === 'BlockStatement' ||
|
|
172
|
+
node.type === 'BreakStatement' ||
|
|
173
|
+
node.type === 'ClassDeclaration' ||
|
|
174
|
+
node.type === 'ContinueStatement' ||
|
|
175
|
+
node.type === 'DebuggerStatement' ||
|
|
176
|
+
node.type === 'DeclareClass' ||
|
|
177
|
+
node.type === 'DeclareVariable' ||
|
|
178
|
+
node.type === 'DeclareFunction' ||
|
|
179
|
+
node.type === 'DeclareInterface' ||
|
|
180
|
+
node.type === 'DeclareModule' ||
|
|
181
|
+
node.type === 'DeclareOpaqueType' ||
|
|
182
|
+
node.type === 'DeclareTypeAlias' ||
|
|
183
|
+
node.type === 'DoWhileStatement' ||
|
|
184
|
+
node.type === 'EmptyStatement' ||
|
|
185
|
+
node.type === 'EnumDeclaration' ||
|
|
186
|
+
node.type === 'ExpressionStatement' ||
|
|
187
|
+
node.type === 'ForInStatement' ||
|
|
188
|
+
node.type === 'ForOfStatement' ||
|
|
189
|
+
node.type === 'ForStatement' ||
|
|
190
|
+
node.type === 'FunctionDeclaration' ||
|
|
191
|
+
node.type === 'IfStatement' ||
|
|
192
|
+
node.type === 'InterfaceDeclaration' ||
|
|
193
|
+
node.type === 'LabeledStatement' ||
|
|
194
|
+
node.type === 'OpaqueType' ||
|
|
195
|
+
node.type === 'ReturnStatement' ||
|
|
196
|
+
node.type === 'SwitchStatement' ||
|
|
197
|
+
node.type === 'ThrowStatement' ||
|
|
198
|
+
node.type === 'TryStatement' ||
|
|
199
|
+
node.type === 'TypeAlias' ||
|
|
200
|
+
node.type === 'VariableDeclaration' ||
|
|
201
|
+
node.type === 'WhileStatement' ||
|
|
202
|
+
node.type === 'WithStatement'
|
|
257
203
|
);
|
|
258
204
|
}
|
package/dist/types.js.flow
CHANGED
|
@@ -192,10 +192,12 @@ export type ESNode =
|
|
|
192
192
|
| HookDeclaration
|
|
193
193
|
| EnumDeclaration
|
|
194
194
|
| EnumNumberBody
|
|
195
|
+
| EnumBigIntBody
|
|
195
196
|
| EnumStringBody
|
|
196
197
|
| EnumStringMember
|
|
197
198
|
| EnumDefaultedMember
|
|
198
199
|
| EnumNumberMember
|
|
200
|
+
| EnumBigIntMember
|
|
199
201
|
| EnumBooleanBody
|
|
200
202
|
| EnumBooleanMember
|
|
201
203
|
| EnumSymbolBody
|
|
@@ -465,6 +467,7 @@ export type Expression =
|
|
|
465
467
|
| ChainExpression
|
|
466
468
|
| TypeCastExpression
|
|
467
469
|
| AsExpression
|
|
470
|
+
| AsConstExpression
|
|
468
471
|
| JSXFragment
|
|
469
472
|
| JSXElement;
|
|
470
473
|
|
|
@@ -1286,6 +1289,7 @@ export interface KeyofTypeAnnotation extends BaseNode {
|
|
|
1286
1289
|
export interface TupleTypeAnnotation extends BaseNode {
|
|
1287
1290
|
+type: 'TupleTypeAnnotation';
|
|
1288
1291
|
+types: $ReadOnlyArray<TypeAnnotationType>;
|
|
1292
|
+
+inexact: boolean;
|
|
1289
1293
|
}
|
|
1290
1294
|
export interface TupleTypeSpreadElement extends BaseNode {
|
|
1291
1295
|
+type: 'TupleTypeSpreadElement';
|
|
@@ -1369,7 +1373,7 @@ export interface TypePredicate extends BaseNode {
|
|
|
1369
1373
|
+type: 'TypePredicate';
|
|
1370
1374
|
+parameterName: Identifier;
|
|
1371
1375
|
+typeAnnotation: TypeAnnotationType | null;
|
|
1372
|
-
+
|
|
1376
|
+
+kind: null | 'asserts' | 'implies';
|
|
1373
1377
|
}
|
|
1374
1378
|
|
|
1375
1379
|
export interface FunctionTypeAnnotation extends BaseNode {
|
|
@@ -1536,6 +1540,10 @@ export interface AsExpression extends BaseNode {
|
|
|
1536
1540
|
+expression: Expression;
|
|
1537
1541
|
+typeAnnotation: TypeAnnotationType;
|
|
1538
1542
|
}
|
|
1543
|
+
export interface AsConstExpression extends BaseNode {
|
|
1544
|
+
+type: 'AsConstExpression';
|
|
1545
|
+
+expression: Expression;
|
|
1546
|
+
}
|
|
1539
1547
|
|
|
1540
1548
|
interface BaseInterfaceNode extends BaseNode {
|
|
1541
1549
|
+body: ObjectTypeAnnotation;
|
|
@@ -1552,7 +1560,7 @@ export interface InterfaceDeclaration extends BaseInterfaceDeclaration {
|
|
|
1552
1560
|
|
|
1553
1561
|
export interface InterfaceExtends extends BaseNode {
|
|
1554
1562
|
+type: 'InterfaceExtends';
|
|
1555
|
-
+id: Identifier;
|
|
1563
|
+
+id: Identifier | QualifiedTypeIdentifier;
|
|
1556
1564
|
+typeParameters: null | TypeParameterInstantiation;
|
|
1557
1565
|
|
|
1558
1566
|
+parent: InterfaceDeclaration | DeclareInterface;
|
|
@@ -1596,7 +1604,12 @@ export interface TypeParameterInstantiation extends BaseNode {
|
|
|
1596
1604
|
export interface EnumDeclaration extends BaseNode {
|
|
1597
1605
|
+type: 'EnumDeclaration';
|
|
1598
1606
|
+id: Identifier;
|
|
1599
|
-
+body:
|
|
1607
|
+
+body:
|
|
1608
|
+
| EnumNumberBody
|
|
1609
|
+
| EnumBigIntBody
|
|
1610
|
+
| EnumStringBody
|
|
1611
|
+
| EnumBooleanBody
|
|
1612
|
+
| EnumSymbolBody;
|
|
1600
1613
|
}
|
|
1601
1614
|
|
|
1602
1615
|
interface BaseEnumBody extends BaseNode {
|
|
@@ -1623,6 +1636,23 @@ export interface EnumNumberMember extends BaseNode {
|
|
|
1623
1636
|
+parent: EnumNumberBody;
|
|
1624
1637
|
}
|
|
1625
1638
|
|
|
1639
|
+
export interface EnumBigIntBody extends BaseInferrableEnumBody {
|
|
1640
|
+
+type: 'EnumBigIntBody';
|
|
1641
|
+
// enum bigint members cannot be defaulted
|
|
1642
|
+
+members: $ReadOnlyArray<EnumBigIntMember>;
|
|
1643
|
+
+explicitType: boolean;
|
|
1644
|
+
|
|
1645
|
+
+parent: EnumDeclaration;
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
export interface EnumBigIntMember extends BaseNode {
|
|
1649
|
+
+type: 'EnumBigIntMember';
|
|
1650
|
+
+id: Identifier;
|
|
1651
|
+
+init: BigIntLiteral;
|
|
1652
|
+
|
|
1653
|
+
+parent: EnumBigIntBody;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1626
1656
|
export interface EnumStringBody extends BaseInferrableEnumBody {
|
|
1627
1657
|
+type: 'EnumStringBody';
|
|
1628
1658
|
+members: $ReadOnlyArray<EnumStringMember | EnumDefaultedMember>;
|