hermes-estree 0.8.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.
- package/dist/generated/HermesESTreeSelectorTypes.js.flow +19 -0
- package/dist/generated/predicates.js +23 -11
- package/dist/generated/predicates.js.flow +33 -22
- package/dist/predicates.js +13 -1
- package/dist/predicates.js.flow +125 -2
- package/dist/types.js.flow +227 -53
- package/package.json +4 -2
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
1098
|
-
node.value === 'type'
|
|
1108
|
+
(node.type === 'Identifier' && node.name === 'type') ||
|
|
1109
|
+
(node.type === 'Keyword' && node.value === 'type')
|
|
1099
1110
|
);
|
|
1100
1111
|
}
|
|
1101
1112
|
|
package/dist/predicates.js
CHANGED
|
@@ -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
|
}
|
package/dist/predicates.js.flow
CHANGED
|
@@ -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
|
-
|
|
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
|
+
}
|
package/dist/types.js.flow
CHANGED
|
@@ -38,7 +38,10 @@
|
|
|
38
38
|
|
|
39
39
|
export type Range = [number, number];
|
|
40
40
|
|
|
41
|
-
export interface
|
|
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
|
}
|
|
@@ -221,34 +224,38 @@ export type AFunction =
|
|
|
221
224
|
| ArrowFunctionExpression;
|
|
222
225
|
|
|
223
226
|
export type Statement =
|
|
224
|
-
| ExpressionStatement
|
|
225
227
|
| BlockStatement
|
|
226
|
-
| EmptyStatement
|
|
227
|
-
| DebuggerStatement
|
|
228
|
-
| WithStatement
|
|
229
|
-
| ReturnStatement
|
|
230
|
-
| LabeledStatement
|
|
231
228
|
| BreakStatement
|
|
229
|
+
| ClassDeclaration
|
|
232
230
|
| ContinueStatement
|
|
231
|
+
| DebuggerStatement
|
|
232
|
+
| DeclareClass
|
|
233
|
+
| DeclareVariable
|
|
234
|
+
| DeclareFunction
|
|
235
|
+
| DeclareInterface
|
|
236
|
+
| DeclareModule
|
|
237
|
+
| DeclareOpaqueType
|
|
238
|
+
| DeclareTypeAlias
|
|
239
|
+
| DoWhileStatement
|
|
240
|
+
| EmptyStatement
|
|
241
|
+
| EnumDeclaration
|
|
242
|
+
| ExpressionStatement
|
|
243
|
+
| ForInStatement
|
|
244
|
+
| ForOfStatement
|
|
245
|
+
| ForStatement
|
|
246
|
+
| FunctionDeclaration
|
|
233
247
|
| IfStatement
|
|
248
|
+
| InterfaceDeclaration
|
|
249
|
+
| LabeledStatement
|
|
250
|
+
| OpaqueType
|
|
251
|
+
| ReturnStatement
|
|
234
252
|
| SwitchStatement
|
|
235
253
|
| ThrowStatement
|
|
236
254
|
| TryStatement
|
|
237
|
-
| WhileStatement
|
|
238
|
-
| DoWhileStatement
|
|
239
|
-
| ForStatement
|
|
240
|
-
| ForInStatement
|
|
241
|
-
| ForOfStatement
|
|
242
255
|
| TypeAlias
|
|
243
|
-
| OpaqueType
|
|
244
|
-
| InterfaceDeclaration
|
|
245
|
-
| FunctionDeclaration
|
|
246
256
|
| VariableDeclaration
|
|
247
|
-
|
|
|
248
|
-
|
|
|
249
|
-
| DeclareOpaqueType
|
|
250
|
-
| DeclareInterface
|
|
251
|
-
| DeclareModule;
|
|
257
|
+
| WhileStatement
|
|
258
|
+
| WithStatement;
|
|
252
259
|
|
|
253
260
|
// nodes that can be the direct parent of a statement
|
|
254
261
|
export type StatementParentSingle =
|
|
@@ -388,6 +395,8 @@ export interface VariableDeclarator extends BaseNode {
|
|
|
388
395
|
+type: 'VariableDeclarator';
|
|
389
396
|
+id: BindingName;
|
|
390
397
|
+init?: Expression | null;
|
|
398
|
+
|
|
399
|
+
+parent: VariableDeclaration;
|
|
391
400
|
}
|
|
392
401
|
|
|
393
402
|
export type Expression =
|
|
@@ -445,7 +454,11 @@ export type ObjectProperty =
|
|
|
445
454
|
| ObjectPropertyWithNonShorthandStaticName
|
|
446
455
|
| ObjectPropertyWithShorthandStaticName
|
|
447
456
|
| ObjectPropertyWithComputedName;
|
|
448
|
-
|
|
457
|
+
interface ObjectPropertyBase extends BaseNode {
|
|
458
|
+
+parent: ObjectExpression | ObjectPattern;
|
|
459
|
+
}
|
|
460
|
+
export interface ObjectPropertyWithNonShorthandStaticName
|
|
461
|
+
extends ObjectPropertyBase {
|
|
449
462
|
+type: 'Property';
|
|
450
463
|
+computed: false;
|
|
451
464
|
// non-computed, non-shorthand names are constrained significantly
|
|
@@ -455,7 +468,8 @@ export interface ObjectPropertyWithNonShorthandStaticName extends BaseNode {
|
|
|
455
468
|
+method: boolean;
|
|
456
469
|
+shorthand: false;
|
|
457
470
|
}
|
|
458
|
-
export interface ObjectPropertyWithShorthandStaticName
|
|
471
|
+
export interface ObjectPropertyWithShorthandStaticName
|
|
472
|
+
extends ObjectPropertyBase {
|
|
459
473
|
+type: 'Property';
|
|
460
474
|
+computed: false;
|
|
461
475
|
// shorthand keys *must* be identifiers
|
|
@@ -463,10 +477,10 @@ export interface ObjectPropertyWithShorthandStaticName extends BaseNode {
|
|
|
463
477
|
// shorthand values *must* be identifiers (that look the same as the key)
|
|
464
478
|
+value: Identifier;
|
|
465
479
|
+kind: 'init';
|
|
466
|
-
+method:
|
|
480
|
+
+method: false;
|
|
467
481
|
+shorthand: true;
|
|
468
482
|
}
|
|
469
|
-
export interface ObjectPropertyWithComputedName extends
|
|
483
|
+
export interface ObjectPropertyWithComputedName extends ObjectPropertyBase {
|
|
470
484
|
+type: 'Property';
|
|
471
485
|
+computed: true;
|
|
472
486
|
// computed names can be any expression
|
|
@@ -486,6 +500,8 @@ interface DestructuringObjectPropertyBase extends BaseNode {
|
|
|
486
500
|
// destructuring properties cannot be methods
|
|
487
501
|
+kind: 'init';
|
|
488
502
|
+method: false;
|
|
503
|
+
|
|
504
|
+
+parent: ObjectExpression | ObjectPattern;
|
|
489
505
|
}
|
|
490
506
|
export interface DestructuringObjectPropertyWithNonShorthandStaticName
|
|
491
507
|
extends DestructuringObjectPropertyBase {
|
|
@@ -840,7 +856,7 @@ interface BaseClass extends BaseNode {
|
|
|
840
856
|
+body: ClassBody;
|
|
841
857
|
|
|
842
858
|
+typeParameters: null | TypeParameterDeclaration;
|
|
843
|
-
+superTypeParameters: null |
|
|
859
|
+
+superTypeParameters: null | TypeParameterInstantiation;
|
|
844
860
|
+implements: $ReadOnlyArray<ClassImplements>;
|
|
845
861
|
+decorators: $ReadOnlyArray<Decorator>;
|
|
846
862
|
}
|
|
@@ -862,6 +878,8 @@ export type ClassMemberWithNonComputedName =
|
|
|
862
878
|
export interface ClassBody extends BaseNode {
|
|
863
879
|
+type: 'ClassBody';
|
|
864
880
|
+body: $ReadOnlyArray<ClassMember>;
|
|
881
|
+
|
|
882
|
+
+parent: AClass;
|
|
865
883
|
}
|
|
866
884
|
|
|
867
885
|
export type MethodDefinition =
|
|
@@ -870,6 +888,8 @@ export type MethodDefinition =
|
|
|
870
888
|
| MethodDefinitionWithNonComputedName;
|
|
871
889
|
interface MethodDefinitionBase extends BaseNode {
|
|
872
890
|
+value: FunctionExpression;
|
|
891
|
+
|
|
892
|
+
+parent: ClassBody;
|
|
873
893
|
}
|
|
874
894
|
export interface MethodDefinitionConstructor extends MethodDefinitionBase {
|
|
875
895
|
+type: 'MethodDefinition';
|
|
@@ -906,6 +926,8 @@ interface PropertyDefinitionBase extends BaseNode {
|
|
|
906
926
|
+declare: boolean;
|
|
907
927
|
// hermes always emit this as false
|
|
908
928
|
+optional: false;
|
|
929
|
+
|
|
930
|
+
+parent: ClassBody;
|
|
909
931
|
}
|
|
910
932
|
export interface PropertyDefinitionWithComputedName
|
|
911
933
|
extends PropertyDefinitionBase {
|
|
@@ -966,6 +988,8 @@ export interface ImportAttribute extends BaseNode {
|
|
|
966
988
|
+type: 'ImportAttribute';
|
|
967
989
|
+key: Identifier;
|
|
968
990
|
+value: StringLiteral;
|
|
991
|
+
|
|
992
|
+
+parent: ImportDeclaration | ImportExpression;
|
|
969
993
|
}
|
|
970
994
|
|
|
971
995
|
export interface ImportSpecifier extends BaseNode {
|
|
@@ -973,6 +997,8 @@ export interface ImportSpecifier extends BaseNode {
|
|
|
973
997
|
+imported: Identifier;
|
|
974
998
|
+local: Identifier;
|
|
975
999
|
+importKind: null | 'type' | 'typeof';
|
|
1000
|
+
|
|
1001
|
+
+parent: ImportDeclaration;
|
|
976
1002
|
}
|
|
977
1003
|
|
|
978
1004
|
export interface ImportExpression extends BaseNode {
|
|
@@ -984,11 +1010,15 @@ export interface ImportExpression extends BaseNode {
|
|
|
984
1010
|
export interface ImportDefaultSpecifier extends BaseNode {
|
|
985
1011
|
+type: 'ImportDefaultSpecifier';
|
|
986
1012
|
+local: Identifier;
|
|
1013
|
+
|
|
1014
|
+
+parent: ImportDeclaration;
|
|
987
1015
|
}
|
|
988
1016
|
|
|
989
1017
|
export interface ImportNamespaceSpecifier extends BaseNode {
|
|
990
1018
|
+type: 'ImportNamespaceSpecifier';
|
|
991
1019
|
+local: Identifier;
|
|
1020
|
+
|
|
1021
|
+
+parent: ImportDeclaration;
|
|
992
1022
|
}
|
|
993
1023
|
|
|
994
1024
|
export type DefaultDeclaration = FunctionDeclaration | ClassDeclaration;
|
|
@@ -1000,13 +1030,30 @@ export type NamedDeclaration =
|
|
|
1000
1030
|
| InterfaceDeclaration
|
|
1001
1031
|
| EnumDeclaration;
|
|
1002
1032
|
|
|
1003
|
-
|
|
1033
|
+
interface ExportNamedDeclarationBase extends BaseNode {
|
|
1004
1034
|
+type: 'ExportNamedDeclaration';
|
|
1005
1035
|
+declaration?: NamedDeclaration | null;
|
|
1006
1036
|
+specifiers: $ReadOnlyArray<ExportSpecifier>;
|
|
1007
|
-
+source?:
|
|
1037
|
+
+source?: StringLiteral | null;
|
|
1008
1038
|
+exportKind: 'value' | 'type';
|
|
1009
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;
|
|
1010
1057
|
|
|
1011
1058
|
export interface ExportSpecifier extends BaseNode {
|
|
1012
1059
|
+type: 'ExportSpecifier';
|
|
@@ -1021,7 +1068,7 @@ export interface ExportDefaultDeclaration extends BaseNode {
|
|
|
1021
1068
|
|
|
1022
1069
|
export interface ExportAllDeclaration extends BaseNode {
|
|
1023
1070
|
+type: 'ExportAllDeclaration';
|
|
1024
|
-
+source:
|
|
1071
|
+
+source: StringLiteral;
|
|
1025
1072
|
+exportKind: 'value' | 'type';
|
|
1026
1073
|
+exported?: Identifier | null;
|
|
1027
1074
|
}
|
|
@@ -1038,6 +1085,7 @@ export interface AwaitExpression extends BaseNode {
|
|
|
1038
1085
|
export type TypeAnnotationType =
|
|
1039
1086
|
| NumberTypeAnnotation
|
|
1040
1087
|
| StringTypeAnnotation
|
|
1088
|
+
| BigIntTypeAnnotation
|
|
1041
1089
|
| BooleanTypeAnnotation
|
|
1042
1090
|
| NullLiteralTypeAnnotation
|
|
1043
1091
|
| AnyTypeAnnotation
|
|
@@ -1101,6 +1149,9 @@ export interface NumberTypeAnnotation extends BaseNode {
|
|
|
1101
1149
|
export interface StringTypeAnnotation extends BaseNode {
|
|
1102
1150
|
+type: 'StringTypeAnnotation';
|
|
1103
1151
|
}
|
|
1152
|
+
export interface BigIntTypeAnnotation extends BaseNode {
|
|
1153
|
+
+type: 'BigIntTypeAnnotation';
|
|
1154
|
+
}
|
|
1104
1155
|
export interface BooleanTypeAnnotation extends BaseNode {
|
|
1105
1156
|
+type: 'BooleanTypeAnnotation';
|
|
1106
1157
|
}
|
|
@@ -1137,13 +1188,14 @@ export interface NumberLiteralTypeAnnotation extends BaseNode {
|
|
|
1137
1188
|
}
|
|
1138
1189
|
export interface BigIntLiteralTypeAnnotation extends BaseNode {
|
|
1139
1190
|
+type: 'BigIntLiteralTypeAnnotation';
|
|
1140
|
-
+
|
|
1191
|
+
+bigint: string;
|
|
1192
|
+
+value: null /* | bigint */;
|
|
1141
1193
|
+raw: string;
|
|
1142
1194
|
}
|
|
1143
1195
|
export interface BooleanLiteralTypeAnnotation extends BaseNode {
|
|
1144
1196
|
+type: 'BooleanLiteralTypeAnnotation';
|
|
1145
1197
|
+value: boolean;
|
|
1146
|
-
+raw:
|
|
1198
|
+
+raw: 'true' | 'false';
|
|
1147
1199
|
}
|
|
1148
1200
|
export interface ArrayTypeAnnotation extends BaseNode {
|
|
1149
1201
|
+type: 'ArrayTypeAnnotation';
|
|
@@ -1172,7 +1224,7 @@ export interface TypeofTypeAnnotation extends BaseNode {
|
|
|
1172
1224
|
}
|
|
1173
1225
|
export interface TupleTypeAnnotation extends BaseNode {
|
|
1174
1226
|
+type: 'TupleTypeAnnotation';
|
|
1175
|
-
+types: TypeAnnotationType
|
|
1227
|
+
+types: $ReadOnlyArray<TypeAnnotationType>;
|
|
1176
1228
|
}
|
|
1177
1229
|
|
|
1178
1230
|
// type T = { [[foo]]: number };
|
|
@@ -1183,6 +1235,8 @@ export interface ObjectTypeInternalSlot extends BaseNode {
|
|
|
1183
1235
|
+static: boolean;
|
|
1184
1236
|
+method: boolean;
|
|
1185
1237
|
+value: TypeAnnotation;
|
|
1238
|
+
|
|
1239
|
+
+parent: ObjectTypeAnnotation;
|
|
1186
1240
|
}
|
|
1187
1241
|
|
|
1188
1242
|
export interface InterfaceTypeAnnotation extends BaseInterfaceNode {
|
|
@@ -1204,16 +1258,20 @@ export interface FunctionTypeAnnotation extends BaseNode {
|
|
|
1204
1258
|
+returnType: TypeAnnotationType;
|
|
1205
1259
|
+rest: null | FunctionTypeParam;
|
|
1206
1260
|
+typeParameters: null | TypeParameterDeclaration;
|
|
1207
|
-
+this:
|
|
1261
|
+
+this: FunctionTypeParam | null;
|
|
1208
1262
|
}
|
|
1209
1263
|
export interface FunctionTypeParam extends BaseNode {
|
|
1210
1264
|
+type: 'FunctionTypeParam';
|
|
1211
1265
|
+name: Identifier | null;
|
|
1212
1266
|
+typeAnnotation: TypeAnnotationType;
|
|
1213
1267
|
+optional: boolean;
|
|
1268
|
+
|
|
1269
|
+
+parent: FunctionTypeAnnotation;
|
|
1214
1270
|
}
|
|
1215
1271
|
export interface InferredPredicate extends BaseNode {
|
|
1216
1272
|
+type: 'InferredPredicate';
|
|
1273
|
+
|
|
1274
|
+
+parent: AFunction | DeclareFunction;
|
|
1217
1275
|
}
|
|
1218
1276
|
|
|
1219
1277
|
export interface ObjectTypeAnnotation extends BaseNode {
|
|
@@ -1225,44 +1283,87 @@ export interface ObjectTypeAnnotation extends BaseNode {
|
|
|
1225
1283
|
+callProperties: $ReadOnlyArray<ObjectTypeCallProperty>;
|
|
1226
1284
|
+internalSlots: $ReadOnlyArray<ObjectTypeInternalSlot>;
|
|
1227
1285
|
}
|
|
1228
|
-
|
|
1286
|
+
interface ObjectTypePropertyBase extends BaseNode {
|
|
1229
1287
|
+type: 'ObjectTypeProperty';
|
|
1230
|
-
+key: Identifier;
|
|
1288
|
+
+key: Identifier | StringLiteral;
|
|
1231
1289
|
+value: TypeAnnotationType;
|
|
1232
1290
|
+method: boolean;
|
|
1233
1291
|
+optional: boolean;
|
|
1234
|
-
+static:
|
|
1235
|
-
+proto:
|
|
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;
|
|
1236
1314
|
+variance: Variance | null;
|
|
1237
1315
|
+kind: 'init';
|
|
1316
|
+
|
|
1317
|
+
+parent: ObjectTypeAnnotation;
|
|
1238
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
|
+
|
|
1239
1334
|
export interface ObjectTypeCallProperty extends BaseNode {
|
|
1240
1335
|
+type: 'ObjectTypeCallProperty';
|
|
1241
1336
|
+value: FunctionTypeAnnotation;
|
|
1242
|
-
+static:
|
|
1337
|
+
+static: boolean; // can only be static when defined on a declare class
|
|
1338
|
+
|
|
1339
|
+
+parent: ObjectTypeAnnotation;
|
|
1243
1340
|
}
|
|
1244
1341
|
export interface ObjectTypeIndexer extends BaseNode {
|
|
1245
1342
|
+type: 'ObjectTypeIndexer';
|
|
1246
1343
|
+id: null | Identifier;
|
|
1247
1344
|
+key: TypeAnnotationType;
|
|
1248
1345
|
+value: TypeAnnotationType;
|
|
1249
|
-
+static:
|
|
1346
|
+
+static: boolean; // can only be static when defined on a declare class
|
|
1250
1347
|
+variance: null | Variance;
|
|
1348
|
+
|
|
1349
|
+
+parent: ObjectTypeAnnotation;
|
|
1251
1350
|
}
|
|
1252
1351
|
export interface ObjectTypeSpreadProperty extends BaseNode {
|
|
1253
1352
|
+type: 'ObjectTypeSpreadProperty';
|
|
1254
1353
|
+argument: TypeAnnotationType;
|
|
1354
|
+
|
|
1355
|
+
+parent: ObjectTypeAnnotation;
|
|
1255
1356
|
}
|
|
1256
1357
|
|
|
1257
1358
|
export interface IndexedAccessType extends BaseNode {
|
|
1258
1359
|
+type: 'IndexedAccessType';
|
|
1259
|
-
+objectType:
|
|
1260
|
-
+indexType:
|
|
1360
|
+
+objectType: TypeAnnotationType;
|
|
1361
|
+
+indexType: TypeAnnotationType;
|
|
1261
1362
|
}
|
|
1262
1363
|
export interface OptionalIndexedAccessType extends BaseNode {
|
|
1263
1364
|
+type: 'OptionalIndexedAccessType';
|
|
1264
|
-
+objectType:
|
|
1265
|
-
+indexType:
|
|
1365
|
+
+objectType: TypeAnnotationType;
|
|
1366
|
+
+indexType: TypeAnnotationType;
|
|
1266
1367
|
+optional: boolean;
|
|
1267
1368
|
}
|
|
1268
1369
|
|
|
@@ -1288,18 +1389,24 @@ export interface InterfaceDeclaration extends BaseInterfaceDeclaration {
|
|
|
1288
1389
|
export interface InterfaceExtends extends BaseNode {
|
|
1289
1390
|
+type: 'InterfaceExtends';
|
|
1290
1391
|
+id: Identifier;
|
|
1291
|
-
+typeParameters: null |
|
|
1392
|
+
+typeParameters: null | TypeParameterInstantiation;
|
|
1393
|
+
|
|
1394
|
+
+parent: InterfaceDeclaration | DeclareInterface;
|
|
1292
1395
|
}
|
|
1293
1396
|
|
|
1294
1397
|
export interface ClassImplements extends BaseNode {
|
|
1295
1398
|
+type: 'ClassImplements';
|
|
1296
1399
|
+id: Identifier;
|
|
1297
|
-
+typeParameters: null |
|
|
1400
|
+
+typeParameters: null | TypeParameterInstantiation;
|
|
1401
|
+
|
|
1402
|
+
+parent: AClass | DeclareClass;
|
|
1298
1403
|
}
|
|
1299
1404
|
|
|
1300
1405
|
export interface Decorator extends BaseNode {
|
|
1301
1406
|
+type: 'Decorator';
|
|
1302
1407
|
+expression: Expression;
|
|
1408
|
+
|
|
1409
|
+
+parent: AClass;
|
|
1303
1410
|
}
|
|
1304
1411
|
|
|
1305
1412
|
export interface TypeParameterDeclaration extends BaseNode {
|
|
@@ -1312,10 +1419,14 @@ export interface TypeParameter extends BaseNode {
|
|
|
1312
1419
|
+bound: null | TypeAnnotation;
|
|
1313
1420
|
+variance: null | Variance;
|
|
1314
1421
|
+default: null | TypeAnnotationType;
|
|
1422
|
+
|
|
1423
|
+
+parent: TypeParameterDeclaration;
|
|
1315
1424
|
}
|
|
1316
1425
|
export interface TypeParameterInstantiation extends BaseNode {
|
|
1317
1426
|
+type: 'TypeParameterInstantiation';
|
|
1318
1427
|
+params: $ReadOnlyArray<TypeAnnotationType>;
|
|
1428
|
+
|
|
1429
|
+
+parent: GenericTypeAnnotation | CallExpression | NewExpression;
|
|
1319
1430
|
}
|
|
1320
1431
|
|
|
1321
1432
|
export interface EnumDeclaration extends BaseNode {
|
|
@@ -1336,46 +1447,62 @@ export interface EnumNumberBody extends BaseInferrableEnumBody {
|
|
|
1336
1447
|
// enum number members cannot be defaulted
|
|
1337
1448
|
+members: $ReadOnlyArray<EnumNumberMember>;
|
|
1338
1449
|
+explicitType: boolean;
|
|
1450
|
+
|
|
1451
|
+
+parent: EnumDeclaration;
|
|
1339
1452
|
}
|
|
1340
1453
|
|
|
1341
1454
|
export interface EnumNumberMember extends BaseNode {
|
|
1342
1455
|
+type: 'EnumNumberMember';
|
|
1343
1456
|
+id: Identifier;
|
|
1344
1457
|
+init: NumericLiteral;
|
|
1458
|
+
|
|
1459
|
+
+parent: EnumNumberBody;
|
|
1345
1460
|
}
|
|
1346
1461
|
|
|
1347
1462
|
export interface EnumStringBody extends BaseInferrableEnumBody {
|
|
1348
1463
|
+type: 'EnumStringBody';
|
|
1349
1464
|
+members: $ReadOnlyArray<EnumStringMember | EnumDefaultedMember>;
|
|
1465
|
+
|
|
1466
|
+
+parent: EnumDeclaration;
|
|
1350
1467
|
}
|
|
1351
1468
|
|
|
1352
1469
|
export interface EnumStringMember extends BaseNode {
|
|
1353
1470
|
+type: 'EnumStringMember';
|
|
1354
1471
|
+id: Identifier;
|
|
1355
1472
|
+init: StringLiteral;
|
|
1473
|
+
|
|
1474
|
+
+parent: EnumStringBody;
|
|
1356
1475
|
}
|
|
1357
1476
|
|
|
1358
1477
|
export interface EnumBooleanBody extends BaseInferrableEnumBody {
|
|
1359
1478
|
+type: 'EnumBooleanBody';
|
|
1360
1479
|
// enum boolean members cannot be defaulted
|
|
1361
1480
|
+members: $ReadOnlyArray<EnumBooleanMember>;
|
|
1481
|
+
|
|
1482
|
+
+parent: EnumDeclaration;
|
|
1362
1483
|
}
|
|
1363
1484
|
|
|
1364
1485
|
export interface EnumBooleanMember extends BaseNode {
|
|
1365
1486
|
+type: 'EnumBooleanMember';
|
|
1366
1487
|
+id: Identifier;
|
|
1367
1488
|
+init: BooleanLiteral;
|
|
1489
|
+
|
|
1490
|
+
+parent: EnumBooleanBody;
|
|
1368
1491
|
}
|
|
1369
1492
|
|
|
1370
1493
|
export interface EnumSymbolBody extends BaseEnumBody {
|
|
1371
1494
|
+type: 'EnumSymbolBody';
|
|
1372
1495
|
// enum symbol members can only be defaulted
|
|
1373
1496
|
+members: $ReadOnlyArray<EnumDefaultedMember>;
|
|
1497
|
+
|
|
1498
|
+
+parent: EnumDeclaration;
|
|
1374
1499
|
}
|
|
1375
1500
|
|
|
1376
1501
|
export interface EnumDefaultedMember extends BaseNode {
|
|
1377
1502
|
+type: 'EnumDefaultedMember';
|
|
1378
1503
|
+id: Identifier;
|
|
1504
|
+
|
|
1505
|
+
+parent: EnumStringBody | EnumSymbolBody;
|
|
1379
1506
|
}
|
|
1380
1507
|
|
|
1381
1508
|
/*****************
|
|
@@ -1412,7 +1539,12 @@ export interface DeclareVariable extends BaseNode {
|
|
|
1412
1539
|
|
|
1413
1540
|
export interface DeclareFunction extends BaseNode {
|
|
1414
1541
|
+type: 'DeclareFunction';
|
|
1415
|
-
|
|
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
|
+
};
|
|
1416
1548
|
+predicate: InferredPredicate | DeclaredPredicate | null;
|
|
1417
1549
|
}
|
|
1418
1550
|
|
|
@@ -1441,19 +1573,49 @@ export interface DeclareExportAllDeclaration extends BaseNode {
|
|
|
1441
1573
|
+source: StringLiteral;
|
|
1442
1574
|
}
|
|
1443
1575
|
|
|
1444
|
-
|
|
1576
|
+
interface DeclareExportDeclarationBase extends BaseNode {
|
|
1445
1577
|
+type: 'DeclareExportDeclaration';
|
|
1446
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';
|
|
1447
1595
|
+declaration:
|
|
1448
|
-
| TypeAlias
|
|
1449
1596
|
| DeclareClass
|
|
1450
1597
|
| DeclareFunction
|
|
1451
|
-
| DeclareOpaqueType
|
|
1452
1598
|
| DeclareInterface
|
|
1453
|
-
|
|
|
1454
|
-
|
|
1455
|
-
+default:
|
|
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>;
|
|
1456
1614
|
}
|
|
1615
|
+
export type DeclareExportDeclaration =
|
|
1616
|
+
| DeclareExportDefaultDeclaration
|
|
1617
|
+
| DeclareExportDeclarationNamedWithDeclaration
|
|
1618
|
+
| DeclareExportDeclarationNamedWithSpecifiers;
|
|
1457
1619
|
|
|
1458
1620
|
export interface DeclareModuleExports extends BaseNode {
|
|
1459
1621
|
+type: 'DeclareModuleExports';
|
|
@@ -1502,15 +1664,21 @@ export interface JSXAttribute extends BaseNode {
|
|
|
1502
1664
|
+type: 'JSXAttribute';
|
|
1503
1665
|
+name: JSXIdentifier;
|
|
1504
1666
|
+value: Literal | JSXExpression | null;
|
|
1667
|
+
|
|
1668
|
+
+parent: JSXOpeningElement;
|
|
1505
1669
|
}
|
|
1506
1670
|
|
|
1507
1671
|
export interface JSXClosingElement extends BaseNode {
|
|
1508
1672
|
+type: 'JSXClosingElement';
|
|
1509
1673
|
+name: JSXTagNameExpression;
|
|
1674
|
+
|
|
1675
|
+
+parent: JSXElement;
|
|
1510
1676
|
}
|
|
1511
1677
|
|
|
1512
1678
|
export interface JSXClosingFragment extends BaseNode {
|
|
1513
1679
|
+type: 'JSXClosingFragment';
|
|
1680
|
+
|
|
1681
|
+
+parent: JSXFragment;
|
|
1514
1682
|
}
|
|
1515
1683
|
|
|
1516
1684
|
export interface JSXElement extends BaseNode {
|
|
@@ -1526,7 +1694,7 @@ export interface JSXEmptyExpression extends BaseNode {
|
|
|
1526
1694
|
|
|
1527
1695
|
export interface JSXExpressionContainer extends BaseNode {
|
|
1528
1696
|
+type: 'JSXExpressionContainer';
|
|
1529
|
-
+expression: Expression;
|
|
1697
|
+
+expression: Expression | JSXEmptyExpression;
|
|
1530
1698
|
}
|
|
1531
1699
|
|
|
1532
1700
|
export interface JSXFragment extends BaseNode {
|
|
@@ -1558,15 +1726,21 @@ export interface JSXOpeningElement extends BaseNode {
|
|
|
1558
1726
|
+selfClosing: boolean;
|
|
1559
1727
|
+name: JSXTagNameExpression;
|
|
1560
1728
|
+attributes: $ReadOnlyArray<JSXAttribute | JSXSpreadAttribute>;
|
|
1729
|
+
|
|
1730
|
+
+parent: JSXElement;
|
|
1561
1731
|
}
|
|
1562
1732
|
|
|
1563
1733
|
export interface JSXOpeningFragment extends BaseNode {
|
|
1564
1734
|
+type: 'JSXOpeningFragment';
|
|
1735
|
+
|
|
1736
|
+
+parent: JSXFragment;
|
|
1565
1737
|
}
|
|
1566
1738
|
|
|
1567
1739
|
export interface JSXSpreadAttribute extends BaseNode {
|
|
1568
1740
|
+type: 'JSXSpreadAttribute';
|
|
1569
1741
|
+argument: Expression;
|
|
1742
|
+
|
|
1743
|
+
+parent: JSXOpeningElement;
|
|
1570
1744
|
}
|
|
1571
1745
|
|
|
1572
1746
|
export interface JSXText extends BaseNode {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermes-estree",
|
|
3
|
-
"version": "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",
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"url": "git@github.com:facebook/hermes.git"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"LICENCE",
|
|
14
|
+
"README.md"
|
|
13
15
|
]
|
|
14
16
|
}
|