hermes-transform 0.36.0 → 0.37.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/detachedNode.js +3 -57
- package/dist/detachedNode.js.flow +12 -12
- package/dist/generated/TransformCloneSignatures.js.flow +1 -1
- package/dist/generated/TransformModifySignatures.js.flow +1 -1
- package/dist/generated/TransformReplaceSignatures.js.flow +207 -207
- package/dist/generated/node-types.js +0 -21
- package/dist/generated/node-types.js.flow +1086 -978
- package/dist/generated/special-case-node-types/Comment.js +0 -13
- package/dist/generated/special-case-node-types/Comment.js.flow +2 -2
- package/dist/generated/special-case-node-types/DeclareExportDeclaration.js +0 -12
- package/dist/generated/special-case-node-types/DeclareExportDeclaration.js.flow +10 -10
- package/dist/generated/special-case-node-types/DeclareHook.js +0 -9
- package/dist/generated/special-case-node-types/DeclareHook.js.flow +5 -5
- package/dist/generated/special-case-node-types/ExportNamedDeclaration.js +0 -11
- package/dist/generated/special-case-node-types/ExportNamedDeclaration.js.flow +9 -9
- package/dist/generated/special-case-node-types/Literal.js +1 -12
- package/dist/generated/special-case-node-types/Literal.js.flow +20 -20
- package/dist/generated/special-case-node-types/ObjectTypeProperty.js +0 -10
- package/dist/generated/special-case-node-types/ObjectTypeProperty.js.flow +23 -21
- package/dist/generated/special-case-node-types/Property.js +0 -9
- package/dist/generated/special-case-node-types/Property.js.flow +50 -42
- package/dist/generated/special-case-node-types/misc.js +6 -35
- package/dist/generated/special-case-node-types/misc.js.flow +56 -48
- package/dist/index.js +0 -9
- package/dist/src/detachedNode.js +3 -57
- package/dist/src/generated/node-types.js +0 -21
- package/dist/src/generated/special-case-node-types/Comment.js +0 -13
- package/dist/src/generated/special-case-node-types/DeclareExportDeclaration.js +0 -12
- package/dist/src/generated/special-case-node-types/DeclareHook.js +0 -9
- package/dist/src/generated/special-case-node-types/ExportNamedDeclaration.js +0 -11
- package/dist/src/generated/special-case-node-types/Literal.js +1 -12
- package/dist/src/generated/special-case-node-types/ObjectTypeProperty.js +0 -10
- package/dist/src/generated/special-case-node-types/Property.js +0 -9
- package/dist/src/generated/special-case-node-types/misc.js +6 -35
- package/dist/src/index.js +0 -9
- package/dist/src/transform/Errors.js +0 -9
- package/dist/src/transform/MutationContext.js +1 -28
- package/dist/src/transform/TransformContext.js +0 -18
- package/dist/src/transform/comments/comments.js +12 -78
- package/dist/src/transform/comments/prettier/common/util.js +4 -133
- package/dist/src/transform/comments/prettier/language-js/comments.js +12 -137
- package/dist/src/transform/comments/prettier/language-js/loc.js +1 -13
- package/dist/src/transform/comments/prettier/language-js/printer-estree.js +1 -10
- package/dist/src/transform/comments/prettier/language-js/utils.js +3 -33
- package/dist/src/transform/comments/prettier/main/comments.js +11 -77
- package/dist/src/transform/comments/prettier/utils/get-last.js +0 -8
- package/dist/src/transform/mutations/AddComments.js +0 -9
- package/dist/src/transform/mutations/CloneCommentsTo.js +0 -9
- package/dist/src/transform/mutations/InsertStatement.js +4 -16
- package/dist/src/transform/mutations/ModifyNodeInPlace.js +4 -17
- package/dist/src/transform/mutations/RemoveComment.js +0 -10
- package/dist/src/transform/mutations/RemoveNode.js +1 -23
- package/dist/src/transform/mutations/RemoveStatement.js +0 -16
- package/dist/src/transform/mutations/ReplaceNode.js +2 -16
- package/dist/src/transform/mutations/ReplaceStatementWithMany.js +2 -14
- package/dist/src/transform/mutations/utils/getStatementParent.js +3 -19
- package/dist/src/transform/mutations/utils/isValidModuleDeclarationParent.js +5 -20
- package/dist/src/transform/parse.js +6 -25
- package/dist/src/transform/print.js +9 -35
- package/dist/src/transform/transform.js +0 -9
- package/dist/src/transform/transformAST.js +3 -31
- package/dist/src/traverse/NodeEventGenerator.js +2 -108
- package/dist/src/traverse/SafeEmitter.js +0 -19
- package/dist/src/traverse/esquery.js +0 -18
- package/dist/src/traverse/traverse.js +1 -22
- package/dist/transform/Errors.js +0 -9
- package/dist/transform/MutationContext.js +1 -28
- package/dist/transform/MutationContext.js.flow +3 -3
- package/dist/transform/TransformContext.js +0 -18
- package/dist/transform/TransformContext.js.flow +60 -54
- package/dist/transform/comments/comments.js +12 -78
- package/dist/transform/comments/comments.js.flow +8 -8
- package/dist/transform/comments/prettier/common/util.js +4 -133
- package/dist/transform/comments/prettier/language-js/comments.js +12 -137
- package/dist/transform/comments/prettier/language-js/loc.js +1 -13
- package/dist/transform/comments/prettier/language-js/printer-estree.js +1 -10
- package/dist/transform/comments/prettier/language-js/utils.js +3 -33
- package/dist/transform/comments/prettier/main/comments.js +11 -77
- package/dist/transform/comments/prettier/utils/get-last.js +0 -8
- package/dist/transform/mutations/AddComments.js +0 -9
- package/dist/transform/mutations/AddComments.js.flow +2 -2
- package/dist/transform/mutations/CloneCommentsTo.js +0 -9
- package/dist/transform/mutations/CloneCommentsTo.js.flow +1 -1
- package/dist/transform/mutations/InsertStatement.js +4 -16
- package/dist/transform/mutations/InsertStatement.js.flow +7 -6
- package/dist/transform/mutations/ModifyNodeInPlace.js +4 -17
- package/dist/transform/mutations/ModifyNodeInPlace.js.flow +2 -2
- package/dist/transform/mutations/RemoveComment.js +0 -10
- package/dist/transform/mutations/RemoveComment.js.flow +4 -4
- package/dist/transform/mutations/RemoveNode.js +1 -23
- package/dist/transform/mutations/RemoveNode.js.flow +9 -9
- package/dist/transform/mutations/RemoveStatement.js +0 -16
- package/dist/transform/mutations/RemoveStatement.js.flow +3 -3
- package/dist/transform/mutations/ReplaceNode.js +2 -16
- package/dist/transform/mutations/ReplaceNode.js.flow +6 -6
- package/dist/transform/mutations/ReplaceStatementWithMany.js +2 -14
- package/dist/transform/mutations/ReplaceStatementWithMany.js.flow +7 -8
- package/dist/transform/mutations/utils/getStatementParent.js +3 -19
- package/dist/transform/mutations/utils/getStatementParent.js.flow +5 -6
- package/dist/transform/mutations/utils/isValidModuleDeclarationParent.js +5 -20
- package/dist/transform/mutations/utils/isValidModuleDeclarationParent.js.flow +4 -3
- package/dist/transform/parse.js +6 -25
- package/dist/transform/print.js +9 -35
- package/dist/transform/print.js.flow +7 -15
- package/dist/transform/transform.js +0 -9
- package/dist/transform/transformAST.js +3 -31
- package/dist/traverse/NodeEventGenerator.js +2 -108
- package/dist/traverse/NodeEventGenerator.js.flow +13 -9
- package/dist/traverse/SafeEmitter.js +0 -19
- package/dist/traverse/SafeEmitter.js.flow +2 -2
- package/dist/traverse/esquery.js +0 -18
- package/dist/traverse/esquery.js.flow +10 -10
- package/dist/traverse/traverse.js +1 -22
- package/dist/traverse/traverse.js.flow +4 -4
- package/package.json +7 -12
|
@@ -8,18 +8,7 @@ exports.LineComment = LineComment;
|
|
|
8
8
|
|
|
9
9
|
var _detachedNode = require("../../detachedNode");
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the MIT license found in the
|
|
15
|
-
* LICENSE file in the root directory of this source tree.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @format
|
|
19
|
-
*/
|
|
20
11
|
function LineComment(props) {
|
|
21
|
-
// $FlowExpectedError[prop-missing]
|
|
22
|
-
// $FlowExpectedError[incompatible-type]
|
|
23
12
|
return (0, _detachedNode.detachedProps)(undefined, {
|
|
24
13
|
type: 'Line',
|
|
25
14
|
value: props.value
|
|
@@ -27,8 +16,6 @@ function LineComment(props) {
|
|
|
27
16
|
}
|
|
28
17
|
|
|
29
18
|
function BlockComment(props) {
|
|
30
|
-
// $FlowExpectedError[prop-missing]
|
|
31
|
-
// $FlowExpectedError[incompatible-type]
|
|
32
19
|
return (0, _detachedNode.detachedProps)(undefined, {
|
|
33
20
|
type: 'Block',
|
|
34
21
|
value: props.value
|
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
|
|
16
16
|
import {detachedProps} from '../../detachedNode';
|
|
17
17
|
|
|
18
|
-
export type LineCommentProps = {
|
|
18
|
+
export type LineCommentProps = {readonly value: string};
|
|
19
19
|
export function LineComment(props: LineCommentProps): LineCommentType {
|
|
20
20
|
// $FlowExpectedError[prop-missing]
|
|
21
21
|
// $FlowExpectedError[incompatible-type]
|
|
@@ -25,7 +25,7 @@ export function LineComment(props: LineCommentProps): LineCommentType {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export type BlockCommentProps = {
|
|
28
|
+
export type BlockCommentProps = {readonly value: string};
|
|
29
29
|
export function BlockComment(props: BlockCommentProps): BlockCommentType {
|
|
30
30
|
// $FlowExpectedError[prop-missing]
|
|
31
31
|
// $FlowExpectedError[incompatible-type]
|
|
@@ -9,19 +9,9 @@ exports.DeclareExportDefaultDeclaration = DeclareExportDefaultDeclaration;
|
|
|
9
9
|
|
|
10
10
|
var _detachedNode = require("../../detachedNode");
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @format
|
|
20
|
-
*/
|
|
21
12
|
function DeclareExportDefaultDeclaration(props) {
|
|
22
13
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
23
14
|
type: 'DeclareExportDeclaration',
|
|
24
|
-
// $FlowFixMe[incompatible-type]
|
|
25
15
|
declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
|
|
26
16
|
specifiers: [],
|
|
27
17
|
source: null,
|
|
@@ -34,7 +24,6 @@ function DeclareExportDefaultDeclaration(props) {
|
|
|
34
24
|
function DeclareExportDeclarationNamedWithDeclaration(props) {
|
|
35
25
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
36
26
|
type: 'DeclareExportDeclaration',
|
|
37
|
-
// $FlowFixMe[incompatible-type]
|
|
38
27
|
declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
|
|
39
28
|
specifiers: [],
|
|
40
29
|
source: null,
|
|
@@ -49,7 +38,6 @@ function DeclareExportDeclarationNamedWithSpecifiers(props) {
|
|
|
49
38
|
type: 'DeclareExportDeclaration',
|
|
50
39
|
declaration: null,
|
|
51
40
|
specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNode)(n)),
|
|
52
|
-
// $FlowFixMe[incompatible-type]
|
|
53
41
|
source: (0, _detachedNode.asDetachedNode)(props.source),
|
|
54
42
|
default: false
|
|
55
43
|
});
|
|
@@ -23,13 +23,13 @@ import {
|
|
|
23
23
|
} from '../../detachedNode';
|
|
24
24
|
|
|
25
25
|
export type DeclareExportDefaultDeclarationProps = {
|
|
26
|
-
|
|
26
|
+
readonly declaration?: ?MaybeDetachedNode<
|
|
27
27
|
DeclareExportDefaultDeclarationType['declaration'],
|
|
28
28
|
>,
|
|
29
29
|
};
|
|
30
30
|
export function DeclareExportDefaultDeclaration(props: {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
...Readonly<DeclareExportDefaultDeclarationProps>,
|
|
32
|
+
readonly parent?: ESNode,
|
|
33
33
|
}): DetachedNode<DeclareExportDefaultDeclarationType> {
|
|
34
34
|
const node = detachedProps<DeclareExportDefaultDeclarationType>(
|
|
35
35
|
props.parent,
|
|
@@ -47,13 +47,13 @@ export function DeclareExportDefaultDeclaration(props: {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export type DeclareExportDeclarationNamedWithDeclarationProps = {
|
|
50
|
-
|
|
50
|
+
readonly declaration?: ?MaybeDetachedNode<
|
|
51
51
|
DeclareExportDeclarationNamedWithDeclarationType['declaration'],
|
|
52
52
|
>,
|
|
53
53
|
};
|
|
54
54
|
export function DeclareExportDeclarationNamedWithDeclaration(props: {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
...Readonly<DeclareExportDeclarationNamedWithDeclarationProps>,
|
|
56
|
+
readonly parent?: ESNode,
|
|
57
57
|
}): DetachedNode<DeclareExportDeclarationNamedWithDeclarationType> {
|
|
58
58
|
const node = detachedProps<DeclareExportDeclarationNamedWithDeclarationType>(
|
|
59
59
|
props.parent,
|
|
@@ -71,18 +71,18 @@ export function DeclareExportDeclarationNamedWithDeclaration(props: {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export type DeclareExportDeclarationNamedWithSpecifiersProps = {
|
|
74
|
-
|
|
74
|
+
readonly specifiers: ReadonlyArray<
|
|
75
75
|
MaybeDetachedNode<
|
|
76
76
|
DeclareExportDeclarationNamedWithSpecifiersType['specifiers'][number],
|
|
77
77
|
>,
|
|
78
78
|
>,
|
|
79
|
-
|
|
79
|
+
readonly source?: ?MaybeDetachedNode<
|
|
80
80
|
DeclareExportDeclarationNamedWithSpecifiersType['source'],
|
|
81
81
|
>,
|
|
82
82
|
};
|
|
83
83
|
export function DeclareExportDeclarationNamedWithSpecifiers(props: {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
...Readonly<DeclareExportDeclarationNamedWithSpecifiersProps>,
|
|
85
|
+
readonly parent?: ESNode,
|
|
86
86
|
}): DetachedNode<DeclareExportDeclarationNamedWithSpecifiersType> {
|
|
87
87
|
const node = detachedProps<DeclareExportDeclarationNamedWithSpecifiersType>(
|
|
88
88
|
props.parent,
|
|
@@ -7,15 +7,6 @@ exports.DeclareHook = DeclareHook;
|
|
|
7
7
|
|
|
8
8
|
var _detachedNode = require("../../detachedNode");
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the MIT license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @format
|
|
18
|
-
*/
|
|
19
10
|
function DeclareHook(props) {
|
|
20
11
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
21
12
|
type: 'DeclareHook',
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import type {
|
|
12
12
|
DeclareHook as DeclareHookType,
|
|
13
13
|
ESNode,
|
|
14
|
-
|
|
14
|
+
HookTypeAnnotation as HookTypeAnnotationType,
|
|
15
15
|
} from 'hermes-estree';
|
|
16
16
|
import type {DetachedNode, MaybeDetachedNode} from '../../detachedNode';
|
|
17
17
|
|
|
@@ -25,12 +25,12 @@ import {
|
|
|
25
25
|
// which is super awkward to work with and type - so we flatten the input
|
|
26
26
|
// and put it in the right spot after
|
|
27
27
|
export type DeclareHookProps = {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
readonly name: string,
|
|
29
|
+
readonly functionType: MaybeDetachedNode<HookTypeAnnotationType>,
|
|
30
30
|
};
|
|
31
31
|
export function DeclareHook(props: {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
...Readonly<DeclareHookProps>,
|
|
33
|
+
readonly parent?: ESNode,
|
|
34
34
|
}): DetachedNode<DeclareHookType> {
|
|
35
35
|
const node = detachedProps<DeclareHookType>(props.parent, {
|
|
36
36
|
type: 'DeclareHook',
|
|
@@ -8,19 +8,9 @@ exports.ExportNamedDeclarationWithSpecifiers = ExportNamedDeclarationWithSpecifi
|
|
|
8
8
|
|
|
9
9
|
var _detachedNode = require("../../detachedNode");
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the MIT license found in the
|
|
15
|
-
* LICENSE file in the root directory of this source tree.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @format
|
|
19
|
-
*/
|
|
20
11
|
function ExportNamedDeclarationWithDeclaration(props) {
|
|
21
12
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
22
13
|
type: 'ExportNamedDeclaration',
|
|
23
|
-
// $FlowFixMe[incompatible-type]
|
|
24
14
|
declaration: (0, _detachedNode.asDetachedNode)(props.declaration),
|
|
25
15
|
specifiers: [],
|
|
26
16
|
source: null,
|
|
@@ -35,7 +25,6 @@ function ExportNamedDeclarationWithSpecifiers(props) {
|
|
|
35
25
|
type: 'ExportNamedDeclaration',
|
|
36
26
|
declaration: null,
|
|
37
27
|
specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNode)(n)),
|
|
38
|
-
// $FlowFixMe[incompatible-type]
|
|
39
28
|
source: (0, _detachedNode.asDetachedNode)(props.source),
|
|
40
29
|
exportKind: props.exportKind
|
|
41
30
|
});
|
|
@@ -22,14 +22,14 @@ import {
|
|
|
22
22
|
} from '../../detachedNode';
|
|
23
23
|
|
|
24
24
|
export type ExportNamedDeclarationWithDeclarationProps = {
|
|
25
|
-
|
|
25
|
+
readonly declaration?: ?MaybeDetachedNode<
|
|
26
26
|
ExportNamedDeclarationWithDeclarationType['declaration'],
|
|
27
27
|
>,
|
|
28
|
-
|
|
28
|
+
readonly exportKind: ExportNamedDeclarationWithDeclarationType['exportKind'],
|
|
29
29
|
};
|
|
30
30
|
export function ExportNamedDeclarationWithDeclaration(props: {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
...Readonly<ExportNamedDeclarationWithDeclarationProps>,
|
|
32
|
+
readonly parent?: ESNode,
|
|
33
33
|
}): DetachedNode<ExportNamedDeclarationWithDeclarationType> {
|
|
34
34
|
const node = detachedProps<ExportNamedDeclarationWithDeclarationType>(
|
|
35
35
|
props.parent,
|
|
@@ -47,19 +47,19 @@ export function ExportNamedDeclarationWithDeclaration(props: {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export type ExportNamedDeclarationWithSpecifiersProps = {
|
|
50
|
-
|
|
50
|
+
readonly specifiers: ReadonlyArray<
|
|
51
51
|
MaybeDetachedNode<
|
|
52
52
|
ExportNamedDeclarationWithSpecifiersType['specifiers'][number],
|
|
53
53
|
>,
|
|
54
54
|
>,
|
|
55
|
-
|
|
55
|
+
readonly source?: ?MaybeDetachedNode<
|
|
56
56
|
ExportNamedDeclarationWithSpecifiersType['source'],
|
|
57
57
|
>,
|
|
58
|
-
|
|
58
|
+
readonly exportKind: ExportNamedDeclarationWithSpecifiersType['exportKind'],
|
|
59
59
|
};
|
|
60
60
|
export function ExportNamedDeclarationWithSpecifiers(props: {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
...Readonly<ExportNamedDeclarationWithSpecifiersProps>,
|
|
62
|
+
readonly parent?: ESNode,
|
|
63
63
|
}): DetachedNode<ExportNamedDeclarationWithSpecifiersType> {
|
|
64
64
|
const node = detachedProps<ExportNamedDeclarationWithSpecifiersType>(
|
|
65
65
|
props.parent,
|
|
@@ -12,15 +12,6 @@ exports.StringLiteral = StringLiteral;
|
|
|
12
12
|
|
|
13
13
|
var _detachedNode = require("../../detachedNode");
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
17
|
-
*
|
|
18
|
-
* This source code is licensed under the MIT license found in the
|
|
19
|
-
* LICENSE file in the root directory of this source tree.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @format
|
|
23
|
-
*/
|
|
24
15
|
function BigIntLiteral(props) {
|
|
25
16
|
var _props$raw;
|
|
26
17
|
|
|
@@ -57,9 +48,7 @@ function NullLiteral(props = { ...null
|
|
|
57
48
|
value: null,
|
|
58
49
|
raw: 'null'
|
|
59
50
|
});
|
|
60
|
-
}
|
|
61
|
-
// also the value is supposed to be a RegExp instance
|
|
62
|
-
|
|
51
|
+
}
|
|
63
52
|
|
|
64
53
|
function RegExpLiteral(props) {
|
|
65
54
|
const value = new RegExp(props.pattern, props.flags);
|
|
@@ -24,16 +24,16 @@ import {detachedProps} from '../../detachedNode';
|
|
|
24
24
|
// Literals require a "raw" which is added by the estree transform, not hermes.
|
|
25
25
|
|
|
26
26
|
export type BigIntLiteralProps = {
|
|
27
|
-
|
|
27
|
+
readonly value: $FlowFixMe /* bigint | null */,
|
|
28
28
|
/**
|
|
29
29
|
* Only set this if you want to use a source-code representation like 1_1n, etc.
|
|
30
30
|
* By default "raw" will just be the exact number you've given.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
readonly raw?: NumericLiteralType['raw'],
|
|
33
33
|
};
|
|
34
34
|
export function BigIntLiteral(props: {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
...Readonly<BigIntLiteralProps>,
|
|
36
|
+
readonly parent?: ESNode,
|
|
37
37
|
}): DetachedNode<BigIntLiteralType> {
|
|
38
38
|
return detachedProps<BigIntLiteralType>(props.parent, {
|
|
39
39
|
type: 'Literal',
|
|
@@ -44,11 +44,11 @@ export function BigIntLiteral(props: {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export type BooleanLiteralProps = {
|
|
47
|
-
|
|
47
|
+
readonly value: BooleanLiteralType['value'],
|
|
48
48
|
};
|
|
49
49
|
export function BooleanLiteral(props: {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
...Readonly<BooleanLiteralProps>,
|
|
51
|
+
readonly parent?: ESNode,
|
|
52
52
|
}): DetachedNode<BooleanLiteralType> {
|
|
53
53
|
return detachedProps<BooleanLiteralType>(props.parent, {
|
|
54
54
|
type: 'Literal',
|
|
@@ -58,16 +58,16 @@ export function BooleanLiteral(props: {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export type NumericLiteralProps = {
|
|
61
|
-
|
|
61
|
+
readonly value: NumericLiteralType['value'],
|
|
62
62
|
/**
|
|
63
63
|
* Only set this if you want to use a source-code representation like 1e100, 0x11, 1_1, etc.
|
|
64
64
|
* By default "raw" will just be the exact number you've given.
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
readonly raw?: NumericLiteralType['raw'],
|
|
67
67
|
};
|
|
68
68
|
export function NumericLiteral(props: {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
...Readonly<NumericLiteralProps>,
|
|
70
|
+
readonly parent?: ESNode,
|
|
71
71
|
}): DetachedNode<NumericLiteralType> {
|
|
72
72
|
return detachedProps<NumericLiteralType>(props.parent, {
|
|
73
73
|
type: 'Literal',
|
|
@@ -79,7 +79,7 @@ export function NumericLiteral(props: {
|
|
|
79
79
|
export type NullLiteralProps = {};
|
|
80
80
|
export function NullLiteral(
|
|
81
81
|
props: {
|
|
82
|
-
|
|
82
|
+
readonly parent?: ESNode,
|
|
83
83
|
} = {...null},
|
|
84
84
|
): DetachedNode<NullLiteralType> {
|
|
85
85
|
return detachedProps<NullLiteralType>(props.parent, {
|
|
@@ -92,12 +92,12 @@ export function NullLiteral(
|
|
|
92
92
|
// pattern/flags are on a subobject in the estree spec, but are flat on the hermes types
|
|
93
93
|
// also the value is supposed to be a RegExp instance
|
|
94
94
|
export type RegExpLiteralProps = {
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
readonly pattern: RegExpLiteralType['regex']['pattern'],
|
|
96
|
+
readonly flags: RegExpLiteralType['regex']['flags'],
|
|
97
97
|
};
|
|
98
98
|
export function RegExpLiteral(props: {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
...Readonly<RegExpLiteralProps>,
|
|
100
|
+
readonly parent?: ESNode,
|
|
101
101
|
}): DetachedNode<RegExpLiteralType> {
|
|
102
102
|
const value = new RegExp(props.pattern, props.flags);
|
|
103
103
|
return detachedProps<RegExpLiteralType>(props.parent, {
|
|
@@ -112,12 +112,12 @@ export function RegExpLiteral(props: {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
export type StringLiteralProps = {
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
readonly value: StringLiteralType['value'],
|
|
116
|
+
readonly raw?: StringLiteralType['raw'],
|
|
117
117
|
};
|
|
118
118
|
export function StringLiteral(props: {
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
...Readonly<StringLiteralProps>,
|
|
120
|
+
readonly parent?: ESNode,
|
|
121
121
|
}): DetachedNode<StringLiteralType> {
|
|
122
122
|
const hasSingleQuote = props.value.includes('"');
|
|
123
123
|
const hasDoubleQuote = props.value.includes("'");
|
|
@@ -9,15 +9,6 @@ exports.ObjectTypePropertySignature = ObjectTypePropertySignature;
|
|
|
9
9
|
|
|
10
10
|
var _detachedNode = require("../../detachedNode");
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @format
|
|
20
|
-
*/
|
|
21
12
|
function ObjectTypeMethodSignature(props) {
|
|
22
13
|
var _props$proto, _props$static;
|
|
23
14
|
|
|
@@ -48,7 +39,6 @@ function ObjectTypePropertySignature(props) {
|
|
|
48
39
|
proto: (_props$proto2 = props.proto) != null ? _props$proto2 : false,
|
|
49
40
|
static: (_props$static2 = props.static) != null ? _props$static2 : false,
|
|
50
41
|
value: (0, _detachedNode.asDetachedNode)(props.value),
|
|
51
|
-
// $FlowFixMe[incompatible-type]
|
|
52
42
|
variance: (0, _detachedNode.asDetachedNode)(props.variance)
|
|
53
43
|
});
|
|
54
44
|
(0, _detachedNode.setParentPointersInDirectChildren)(node);
|
|
@@ -23,16 +23,16 @@ import {
|
|
|
23
23
|
} from '../../detachedNode';
|
|
24
24
|
|
|
25
25
|
export type ObjectTypeMethodSignatureProps = {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
readonly key: MaybeDetachedNode<ObjectTypeMethodSignatureType['key']>,
|
|
27
|
+
readonly value: MaybeDetachedNode<ObjectTypeMethodSignatureType['value']>,
|
|
28
28
|
|
|
29
29
|
// optional because they only apply to the class decl case
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
readonly static?: ObjectTypeMethodSignatureType['static'],
|
|
31
|
+
readonly proto?: ObjectTypeMethodSignatureType['proto'],
|
|
32
32
|
};
|
|
33
33
|
export function ObjectTypeMethodSignature(props: {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
...Readonly<ObjectTypeMethodSignatureProps>,
|
|
35
|
+
readonly parent?: ESNode,
|
|
36
36
|
}): DetachedNode<ObjectTypeMethodSignatureType> {
|
|
37
37
|
const node = detachedProps<ObjectTypeMethodSignatureType>(props.parent, {
|
|
38
38
|
type: 'ObjectTypeProperty',
|
|
@@ -50,18 +50,20 @@ export function ObjectTypeMethodSignature(props: {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export type ObjectTypePropertySignatureProps = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
readonly key: MaybeDetachedNode<ObjectTypePropertySignatureType['key']>,
|
|
54
|
+
readonly value: MaybeDetachedNode<ObjectTypePropertySignatureType['value']>,
|
|
55
|
+
readonly optional: ObjectTypePropertySignatureType['optional'],
|
|
56
|
+
readonly variance?: ?MaybeDetachedNode<
|
|
57
|
+
ObjectTypePropertySignatureType['variance'],
|
|
58
|
+
>,
|
|
57
59
|
|
|
58
60
|
// optional because they only apply to the class decl case
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
readonly static?: ObjectTypeMethodSignatureType['static'],
|
|
62
|
+
readonly proto?: ObjectTypeMethodSignatureType['proto'],
|
|
61
63
|
};
|
|
62
64
|
export function ObjectTypePropertySignature(props: {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
...Readonly<ObjectTypePropertySignatureProps>,
|
|
66
|
+
readonly parent?: ESNode,
|
|
65
67
|
}): DetachedNode<ObjectTypePropertySignatureType> {
|
|
66
68
|
const node = detachedProps<ObjectTypePropertySignatureType>(props.parent, {
|
|
67
69
|
type: 'ObjectTypeProperty',
|
|
@@ -80,17 +82,17 @@ export function ObjectTypePropertySignature(props: {
|
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
export type ObjectTypeAccessorSignatureProps = {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
readonly key: MaybeDetachedNode<ObjectTypeAccessorSignatureType['key']>,
|
|
86
|
+
readonly value: MaybeDetachedNode<ObjectTypeAccessorSignatureType['value']>,
|
|
87
|
+
readonly kind: ObjectTypeAccessorSignatureType['kind'],
|
|
86
88
|
|
|
87
89
|
// optional because they only apply to the class decl case
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
readonly static?: ObjectTypeMethodSignatureType['static'],
|
|
91
|
+
readonly proto?: ObjectTypeMethodSignatureType['proto'],
|
|
90
92
|
};
|
|
91
93
|
export function ObjectTypeAccessorSignature(props: {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
...Readonly<ObjectTypeAccessorSignatureProps>,
|
|
95
|
+
readonly parent?: ESNode,
|
|
94
96
|
}): DetachedNode<ObjectTypeAccessorSignatureType> {
|
|
95
97
|
const node = detachedProps<ObjectTypeAccessorSignatureType>(props.parent, {
|
|
96
98
|
type: 'ObjectTypeProperty',
|
|
@@ -14,15 +14,6 @@ exports.ObjectPropertyWithShorthandStaticName = ObjectPropertyWithShorthandStati
|
|
|
14
14
|
|
|
15
15
|
var _detachedNode = require("../../detachedNode");
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the MIT license found in the
|
|
21
|
-
* LICENSE file in the root directory of this source tree.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @format
|
|
25
|
-
*/
|
|
26
17
|
function DestructuringObjectProperty(props) {
|
|
27
18
|
const node = (0, _detachedNode.detachedProps)(props.parent, {
|
|
28
19
|
type: 'Property',
|