1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function anyTypeAlias(name) {
|
16 | return require("@babel/types").typeAlias(require("@babel/types").identifier(name), null, require("@babel/types").anyTypeAnnotation());
|
17 | }
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | function exactObjectTypeAnnotation(props) {
|
26 | var typeAnnotation = require("@babel/types").objectTypeAnnotation(props);
|
27 |
|
28 | typeAnnotation.exact = true;
|
29 | return typeAnnotation;
|
30 | }
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | function exportType(name, type) {
|
37 | return require("@babel/types").exportNamedDeclaration(require("@babel/types").typeAlias(require("@babel/types").identifier(name), null, type), [], null);
|
38 | }
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | function importTypes(names, module) {
|
45 | var importDeclaration = require("@babel/types").importDeclaration(names.map(function (name) {
|
46 | return require("@babel/types").importSpecifier(require("@babel/types").identifier(name), require("@babel/types").identifier(name));
|
47 | }), require("@babel/types").stringLiteral(module));
|
48 |
|
49 | importDeclaration.importKind = 'type';
|
50 | return importDeclaration;
|
51 | }
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | function intersectionTypeAnnotation(types) {
|
60 | !(types.length > 0) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayFlowBabelFactories: cannot create an intersection of 0 types') : require("fbjs/lib/invariant")(false) : void 0;
|
61 | return types.length === 1 ? types[0] : require("@babel/types").intersectionTypeAnnotation(types);
|
62 | }
|
63 |
|
64 | function lineComments() {
|
65 | for (var _len = arguments.length, lines = new Array(_len), _key = 0; _key < _len; _key++) {
|
66 | lines[_key] = arguments[_key];
|
67 | }
|
68 |
|
69 | |
70 |
|
71 |
|
72 | return lines.map(function (line) {
|
73 | return {
|
74 | type: 'CommentLine',
|
75 | value: ' ' + line
|
76 | };
|
77 | });
|
78 | }
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | function readOnlyArrayOfType(thing) {
|
85 | return require("@babel/types").genericTypeAnnotation(require("@babel/types").identifier('$ReadOnlyArray'), require("@babel/types").typeParameterInstantiation([thing]));
|
86 | }
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | function readOnlyObjectTypeProperty(key, value) {
|
93 | var prop = require("@babel/types").objectTypeProperty(require("@babel/types").identifier(key), value);
|
94 |
|
95 | prop.variance = require("@babel/types").variance('plus');
|
96 | return prop;
|
97 | }
|
98 |
|
99 | function stringLiteralTypeAnnotation(value) {
|
100 | return require("@babel/types").stringLiteralTypeAnnotation(value);
|
101 | }
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 | function unionTypeAnnotation(types) {
|
110 | !(types.length > 0) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayFlowBabelFactories: cannot create a union of 0 types') : require("fbjs/lib/invariant")(false) : void 0;
|
111 | return types.length === 1 ? types[0] : require("@babel/types").unionTypeAnnotation(types);
|
112 | }
|
113 |
|
114 | module.exports = {
|
115 | anyTypeAlias: anyTypeAlias,
|
116 | exactObjectTypeAnnotation: exactObjectTypeAnnotation,
|
117 | exportType: exportType,
|
118 | importTypes: importTypes,
|
119 | intersectionTypeAnnotation: intersectionTypeAnnotation,
|
120 | lineComments: lineComments,
|
121 | readOnlyArrayOfType: readOnlyArrayOfType,
|
122 | readOnlyObjectTypeProperty: readOnlyObjectTypeProperty,
|
123 | stringLiteralTypeAnnotation: stringLiteralTypeAnnotation,
|
124 | unionTypeAnnotation: unionTypeAnnotation
|
125 | }; |
\ | No newline at end of file |