@react-native/codegen 0.90.0-nightly-20261119-f4f8b6a1f → 0.90.0-nightly-20261120-bbfd39149
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/lib/generators/components/ComponentsGeneratorUtils.js.flow +0 -4
- package/lib/generators/components/CppHelpers.js.flow +0 -1
- package/lib/generators/components/GenerateEventEmitterH.js.flow +0 -1
- package/lib/generators/components/GeneratePropsCpp.js.flow +0 -1
- package/lib/generators/components/GeneratePropsH.js.flow +0 -2
- package/lib/generators/components/GenerateTests.js.flow +0 -2
- package/lib/generators/modules/GenerateModuleH.js +14 -0
- package/lib/generators/modules/GenerateModuleH.js.flow +14 -0
- package/lib/parsers/errors.js +6 -0
- package/lib/parsers/errors.js.flow +11 -0
- package/lib/parsers/flow/components/events.js.flow +0 -2
- package/lib/parsers/flow/components/index.js.flow +0 -1
- package/lib/parsers/parsers-commons.js.flow +0 -2
- package/lib/parsers/parsers-primitives.js.flow +0 -1
- package/lib/parsers/typescript/components/index.js.flow +0 -2
- package/lib/parsers/typescript/modules/index.js +14 -0
- package/lib/parsers/typescript/modules/index.js.flow +26 -0
- package/lib/parsers/typescript/parser.js.flow +0 -1
- package/package.json +1 -1
|
@@ -233,9 +233,7 @@ function getLocalImports(
|
|
|
233
233
|
const objectImports = getImports(objectProps);
|
|
234
234
|
// $FlowFixMe[incompatible-type] the type is guaranteed to be ObjectTypeAnnotation<PropTypeAnnotation>
|
|
235
235
|
const localImports = getLocalImports(objectProps);
|
|
236
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
237
236
|
objectImports.forEach(imports.add, imports);
|
|
238
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
239
237
|
localImports.forEach(imports.add, imports);
|
|
240
238
|
}
|
|
241
239
|
|
|
@@ -243,9 +241,7 @@ function getLocalImports(
|
|
|
243
241
|
imports.add('#include <React/RendererCore.h>');
|
|
244
242
|
const objectImports = getImports(typeAnnotation.properties);
|
|
245
243
|
const localImports = getLocalImports(typeAnnotation.properties);
|
|
246
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
247
244
|
objectImports.forEach(imports.add, imports);
|
|
248
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
249
245
|
localImports.forEach(imports.add, imports);
|
|
250
246
|
}
|
|
251
247
|
});
|
|
@@ -162,7 +162,6 @@ function getImports(
|
|
|
162
162
|
|
|
163
163
|
if (typeAnnotation.type === 'ObjectTypeAnnotation') {
|
|
164
164
|
const objectImports = getImports(typeAnnotation.properties);
|
|
165
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
166
165
|
objectImports.forEach(imports.add, imports);
|
|
167
166
|
}
|
|
168
167
|
});
|
|
@@ -356,7 +356,6 @@ module.exports = {
|
|
|
356
356
|
);
|
|
357
357
|
|
|
358
358
|
const imports = getImports(component.props);
|
|
359
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
360
359
|
imports.forEach(allImports.add, allImports);
|
|
361
360
|
|
|
362
361
|
const replacedTemplate = ComponentTemplate({
|
|
@@ -893,9 +893,7 @@ module.exports = {
|
|
|
893
893
|
const extendsImports = getExtendsImports(component.extendsProps);
|
|
894
894
|
const imports = getLocalImports(component.props);
|
|
895
895
|
|
|
896
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
897
896
|
extendsImports.forEach(allImports.add, allImports);
|
|
898
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
899
897
|
imports.forEach(allImports.add, allImports);
|
|
900
898
|
|
|
901
899
|
const replacedTemplate = ClassTemplate({
|
|
@@ -104,7 +104,6 @@ function getTestCasesForProp(
|
|
|
104
104
|
propName: propName,
|
|
105
105
|
propValue: typeAnnotation.default != null ? typeAnnotation.default : true,
|
|
106
106
|
});
|
|
107
|
-
// $FlowFixMe[incompatible-type]
|
|
108
107
|
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
|
|
109
108
|
* roll out. See https://fburl.com/workplace/4oq3zi07. */
|
|
110
109
|
} else if (typeAnnotation.type === 'IntegerTypeAnnotation') {
|
|
@@ -196,7 +195,6 @@ module.exports = {
|
|
|
196
195
|
const name = `${componentName}Props`;
|
|
197
196
|
|
|
198
197
|
const imports = getImports(component.props);
|
|
199
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
200
198
|
imports.forEach(allImports.add, allImports);
|
|
201
199
|
|
|
202
200
|
return generateTestsString(name, component);
|
|
@@ -154,11 +154,25 @@ const FileTemplate = ({
|
|
|
154
154
|
#include <React/Bridging.h>
|
|
155
155
|
#include <React/NativeModuleCore.h>
|
|
156
156
|
|
|
157
|
+
// JSI provides the argument pointer and corresponding count to generated invokers.
|
|
158
|
+
#ifdef __clang__
|
|
159
|
+
#if __has_warning("-Wunsafe-buffer-usage")
|
|
160
|
+
#pragma clang diagnostic push
|
|
161
|
+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
162
|
+
#endif
|
|
163
|
+
#endif
|
|
164
|
+
|
|
157
165
|
namespace facebook::react {
|
|
158
166
|
|
|
159
167
|
${modules.join('\n\n')}
|
|
160
168
|
|
|
161
169
|
} // namespace facebook::react
|
|
170
|
+
|
|
171
|
+
#ifdef __clang__
|
|
172
|
+
#if __has_warning("-Wunsafe-buffer-usage")
|
|
173
|
+
#pragma clang diagnostic pop
|
|
174
|
+
#endif
|
|
175
|
+
#endif
|
|
162
176
|
`;
|
|
163
177
|
};
|
|
164
178
|
function translatePrimitiveJSTypeToCpp(moduleName, parentObjectAliasName, nullableTypeAnnotation, optional, createErrorMessage, resolveAlias, enumMap) {
|
|
@@ -215,11 +215,25 @@ const FileTemplate = ({
|
|
|
215
215
|
#include <React/Bridging.h>
|
|
216
216
|
#include <React/NativeModuleCore.h>
|
|
217
217
|
|
|
218
|
+
// JSI provides the argument pointer and corresponding count to generated invokers.
|
|
219
|
+
#ifdef __clang__
|
|
220
|
+
#if __has_warning("-Wunsafe-buffer-usage")
|
|
221
|
+
#pragma clang diagnostic push
|
|
222
|
+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
223
|
+
#endif
|
|
224
|
+
#endif
|
|
225
|
+
|
|
218
226
|
namespace facebook::react {
|
|
219
227
|
|
|
220
228
|
${modules.join('\n\n')}
|
|
221
229
|
|
|
222
230
|
} // namespace facebook::react
|
|
231
|
+
|
|
232
|
+
#ifdef __clang__
|
|
233
|
+
#if __has_warning("-Wunsafe-buffer-usage")
|
|
234
|
+
#pragma clang diagnostic pop
|
|
235
|
+
#endif
|
|
236
|
+
#endif
|
|
223
237
|
`;
|
|
224
238
|
};
|
|
225
239
|
|
package/lib/parsers/errors.js
CHANGED
|
@@ -97,6 +97,11 @@ class UnsupportedObjectPropertyWithIndexerTypeAnnotationParserError extends Pars
|
|
|
97
97
|
super(nativeModuleName, propertyAST, message);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
+
class UnsupportedRecordTypeParserError extends ParserError {
|
|
101
|
+
constructor(nativeModuleName, recordTypeAST) {
|
|
102
|
+
super(nativeModuleName, recordTypeAST, "'Record' is only supported as Record<string, T>.");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
100
105
|
class UnsupportedObjectPropertyValueTypeAnnotationParserError extends ParserError {
|
|
101
106
|
constructor(nativeModuleName, propertyValueAST, propertyName, invalidPropertyValueType) {
|
|
102
107
|
super(nativeModuleName, propertyValueAST, `Object property '${propertyName}' cannot have type '${invalidPropertyValueType}'.`);
|
|
@@ -185,6 +190,7 @@ module.exports = {
|
|
|
185
190
|
UnsupportedObjectPropertyWithIndexerTypeAnnotationParserError,
|
|
186
191
|
UnsupportedObjectPropertyValueTypeAnnotationParserError,
|
|
187
192
|
UnsupportedObjectDirectRecursivePropertyParserError,
|
|
193
|
+
UnsupportedRecordTypeParserError,
|
|
188
194
|
UnusedModuleInterfaceParserError,
|
|
189
195
|
MoreThanOneModuleRegistryCallsParserError,
|
|
190
196
|
UntypedModuleRegistryCallParserError,
|
|
@@ -261,6 +261,16 @@ class UnsupportedObjectPropertyWithIndexerTypeAnnotationParserError extends Pars
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
class UnsupportedRecordTypeParserError extends ParserError {
|
|
265
|
+
constructor(nativeModuleName: string, recordTypeAST: $FlowFixMe) {
|
|
266
|
+
super(
|
|
267
|
+
nativeModuleName,
|
|
268
|
+
recordTypeAST,
|
|
269
|
+
"'Record' is only supported as Record<string, T>.",
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
264
274
|
class UnsupportedObjectPropertyValueTypeAnnotationParserError extends ParserError {
|
|
265
275
|
constructor(
|
|
266
276
|
nativeModuleName: string,
|
|
@@ -477,6 +487,7 @@ module.exports = {
|
|
|
477
487
|
UnsupportedObjectPropertyWithIndexerTypeAnnotationParserError,
|
|
478
488
|
UnsupportedObjectPropertyValueTypeAnnotationParserError,
|
|
479
489
|
UnsupportedObjectDirectRecursivePropertyParserError,
|
|
490
|
+
UnsupportedRecordTypeParserError,
|
|
480
491
|
UnusedModuleInterfaceParserError,
|
|
481
492
|
MoreThanOneModuleRegistryCallsParserError,
|
|
482
493
|
UntypedModuleRegistryCallParserError,
|
|
@@ -42,8 +42,6 @@ const {
|
|
|
42
42
|
const {getTypeArguments} = require('../../utils');
|
|
43
43
|
|
|
44
44
|
function getPropertyType(
|
|
45
|
-
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
|
|
46
|
-
* LTI update could not be added via codemod */
|
|
47
45
|
name: string,
|
|
48
46
|
optional: boolean,
|
|
49
47
|
typeAnnotation: $FlowFixMe,
|
|
@@ -1131,8 +1131,6 @@ function buildPropSchema(
|
|
|
1131
1131
|
};
|
|
1132
1132
|
}
|
|
1133
1133
|
|
|
1134
|
-
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
|
|
1135
|
-
* LTI update could not be added via codemod */
|
|
1136
1134
|
function getEventArgument(
|
|
1137
1135
|
argumentProps: PropAST,
|
|
1138
1136
|
parser: Parser,
|
|
@@ -21,10 +21,8 @@ const {getCommands} = require('./commands');
|
|
|
21
21
|
const {getEvents} = require('./events');
|
|
22
22
|
const {categorizeProps} = require('./extends');
|
|
23
23
|
|
|
24
|
-
// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser
|
|
25
24
|
type PropsAST = Object;
|
|
26
25
|
|
|
27
|
-
// $FlowFixMe[signature-verification-failure] TODO(T108222691): Use flow-types for @babel/parser
|
|
28
26
|
function buildComponentSchema(
|
|
29
27
|
ast: $FlowFixMe,
|
|
30
28
|
parser: Parser,
|
|
@@ -4,6 +4,7 @@ const {
|
|
|
4
4
|
UnsupportedEnumDeclarationParserError,
|
|
5
5
|
UnsupportedGenericParserError,
|
|
6
6
|
UnsupportedObjectPropertyWithIndexerTypeAnnotationParserError,
|
|
7
|
+
UnsupportedRecordTypeParserError,
|
|
7
8
|
UnsupportedTypeAnnotationParserError
|
|
8
9
|
} = require('../../errors');
|
|
9
10
|
const {
|
|
@@ -24,6 +25,9 @@ const {
|
|
|
24
25
|
typeAliasResolution,
|
|
25
26
|
typeEnumResolution
|
|
26
27
|
} = require('../../parsers-primitives');
|
|
28
|
+
const {
|
|
29
|
+
getTypeArguments
|
|
30
|
+
} = require('../../utils');
|
|
27
31
|
const {
|
|
28
32
|
flattenProperties
|
|
29
33
|
} = require('../components/componentsUtils');
|
|
@@ -66,6 +70,16 @@ function translateTypeReferenceAnnotation(typeName, nullable, typeAnnotation, ha
|
|
|
66
70
|
{
|
|
67
71
|
return emitArrayType(hasteModuleName, typeAnnotation, parser, types, aliasMap, enumMap, cxxOnly, nullable, translateTypeAnnotation);
|
|
68
72
|
}
|
|
73
|
+
case 'Record':
|
|
74
|
+
{
|
|
75
|
+
var _getTypeArguments$par, _getTypeArguments;
|
|
76
|
+
const typeArguments = (_getTypeArguments$par = (_getTypeArguments = getTypeArguments(typeAnnotation)) === null || _getTypeArguments === void 0 ? void 0 : _getTypeArguments.params) !== null && _getTypeArguments$par !== void 0 ? _getTypeArguments$par : [];
|
|
77
|
+
if (typeArguments.length !== 2 || typeArguments[0].type !== 'TSStringKeyword') {
|
|
78
|
+
throw new UnsupportedRecordTypeParserError(hasteModuleName, typeAnnotation);
|
|
79
|
+
}
|
|
80
|
+
const valueType = translateTypeAnnotation(hasteModuleName, typeArguments[1], types, aliasMap, enumMap, tryParse, cxxOnly, parser);
|
|
81
|
+
return emitDictionary(nullable, valueType);
|
|
82
|
+
}
|
|
69
83
|
default:
|
|
70
84
|
{
|
|
71
85
|
const commonType = emitCommonTypes(hasteModuleName, types, typeAnnotation, aliasMap, enumMap, tryParse, cxxOnly, nullable, parser);
|
|
@@ -29,6 +29,7 @@ const {
|
|
|
29
29
|
UnsupportedEnumDeclarationParserError,
|
|
30
30
|
UnsupportedGenericParserError,
|
|
31
31
|
UnsupportedObjectPropertyWithIndexerTypeAnnotationParserError,
|
|
32
|
+
UnsupportedRecordTypeParserError,
|
|
32
33
|
UnsupportedTypeAnnotationParserError,
|
|
33
34
|
} = require('../../errors');
|
|
34
35
|
const {parseObjectProperty} = require('../../parsers-commons');
|
|
@@ -47,6 +48,7 @@ const {
|
|
|
47
48
|
typeAliasResolution,
|
|
48
49
|
typeEnumResolution,
|
|
49
50
|
} = require('../../parsers-primitives');
|
|
51
|
+
const {getTypeArguments} = require('../../utils');
|
|
50
52
|
const {flattenProperties} = require('../components/componentsUtils');
|
|
51
53
|
const {flattenIntersectionType} = require('../parseTopLevelType');
|
|
52
54
|
|
|
@@ -156,6 +158,30 @@ function translateTypeReferenceAnnotation(
|
|
|
156
158
|
translateTypeAnnotation,
|
|
157
159
|
);
|
|
158
160
|
}
|
|
161
|
+
case 'Record': {
|
|
162
|
+
// Record<string, T> is a dictionary, like {[key: string]: T}
|
|
163
|
+
const typeArguments = getTypeArguments(typeAnnotation)?.params ?? [];
|
|
164
|
+
if (
|
|
165
|
+
typeArguments.length !== 2 ||
|
|
166
|
+
typeArguments[0].type !== 'TSStringKeyword'
|
|
167
|
+
) {
|
|
168
|
+
throw new UnsupportedRecordTypeParserError(
|
|
169
|
+
hasteModuleName,
|
|
170
|
+
typeAnnotation,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
const valueType = translateTypeAnnotation(
|
|
174
|
+
hasteModuleName,
|
|
175
|
+
typeArguments[1],
|
|
176
|
+
types,
|
|
177
|
+
aliasMap,
|
|
178
|
+
enumMap,
|
|
179
|
+
tryParse,
|
|
180
|
+
cxxOnly,
|
|
181
|
+
parser,
|
|
182
|
+
);
|
|
183
|
+
return emitDictionary(nullable, valueType);
|
|
184
|
+
}
|
|
159
185
|
default: {
|
|
160
186
|
const commonType = emitCommonTypes(
|
|
161
187
|
hasteModuleName,
|
|
@@ -57,7 +57,6 @@ const {
|
|
|
57
57
|
} = require('./components/componentsUtils');
|
|
58
58
|
const {typeScriptTranslateTypeAnnotation} = require('./modules');
|
|
59
59
|
const {parseTopLevelType} = require('./parseTopLevelType');
|
|
60
|
-
// $FlowFixMe[untyped-import] Use flow-types for @babel/parser
|
|
61
60
|
const babelParser = require('@babel/parser');
|
|
62
61
|
const invariant = require('invariant');
|
|
63
62
|
const fs = require('node:fs');
|