@react-native/codegen 0.72.1 → 0.72.3
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/CodegenSchema.d.ts +348 -0
- package/lib/CodegenSchema.js.flow +31 -3
- package/lib/SchemaValidator.d.ts +11 -0
- package/lib/cli/combine/combine-js-to-schema.js +8 -8
- package/lib/cli/combine/combine-js-to-schema.js.flow +8 -7
- package/lib/cli/parser/parser.js +8 -15
- package/lib/cli/parser/parser.js.flow +8 -14
- package/lib/generators/Utils.js +16 -0
- package/lib/generators/Utils.js.flow +20 -0
- package/lib/generators/__test_fixtures__/fixtures.js +2 -1
- package/lib/generators/__test_fixtures__/fixtures.js.flow +2 -1
- package/lib/generators/components/ComponentsGeneratorUtils.js +10 -1
- package/lib/generators/components/ComponentsGeneratorUtils.js.flow +12 -2
- package/lib/generators/components/CppHelpers.js +8 -15
- package/lib/generators/components/CppHelpers.js.flow +8 -19
- package/lib/generators/components/GenerateEventEmitterCpp.js +7 -3
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +7 -3
- package/lib/generators/components/GenerateEventEmitterH.js +2 -2
- package/lib/generators/components/GenerateEventEmitterH.js.flow +1 -2
- package/lib/generators/components/GeneratePropsH.js +3 -4
- package/lib/generators/components/GeneratePropsH.js.flow +2 -4
- package/lib/generators/components/GeneratePropsJavaDelegate.js +2 -0
- package/lib/generators/components/GeneratePropsJavaDelegate.js.flow +2 -0
- package/lib/generators/components/GeneratePropsJavaInterface.js +3 -0
- package/lib/generators/components/GeneratePropsJavaInterface.js.flow +3 -0
- package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js +8 -0
- package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js.flow +12 -0
- package/lib/generators/components/GenerateTests.js +3 -2
- package/lib/generators/components/GenerateTests.js.flow +3 -1
- package/lib/generators/components/GenerateViewConfigJs.js +5 -2
- package/lib/generators/components/GenerateViewConfigJs.js.flow +5 -2
- package/lib/generators/components/JavaHelpers.js +9 -0
- package/lib/generators/components/JavaHelpers.js.flow +12 -1
- package/lib/generators/components/__test_fixtures__/fixtures.js +41 -0
- package/lib/generators/components/__test_fixtures__/fixtures.js.flow +42 -0
- package/lib/generators/modules/GenerateModuleCpp.js +9 -4
- package/lib/generators/modules/GenerateModuleCpp.js.flow +11 -3
- package/lib/generators/modules/GenerateModuleH.js +185 -33
- package/lib/generators/modules/GenerateModuleH.js.flow +203 -25
- package/lib/generators/modules/GenerateModuleJavaSpec.js +2 -2
- package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +5 -5
- package/lib/generators/modules/GenerateModuleJniCpp.js +2 -2
- package/lib/generators/modules/GenerateModuleJniCpp.js.flow +5 -5
- package/lib/generators/modules/GenerateModuleObjCpp/index.js +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/index.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow +2 -2
- package/lib/generators/modules/Utils.js +4 -0
- package/lib/generators/modules/Utils.js.flow +6 -0
- package/lib/generators/modules/__test_fixtures__/fixtures.js +152 -10
- package/lib/generators/modules/__test_fixtures__/fixtures.js.flow +152 -10
- package/lib/parsers/error-utils.js +42 -19
- package/lib/parsers/error-utils.js.flow +46 -19
- package/lib/parsers/errors.d.ts +10 -0
- package/lib/parsers/errors.js +9 -29
- package/lib/parsers/errors.js.flow +2 -20
- package/lib/parsers/flow/Visitor.js +37 -0
- package/lib/parsers/flow/Visitor.js.flow +41 -0
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js +20 -2
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow +20 -2
- package/lib/parsers/flow/components/commands.js +3 -0
- package/lib/parsers/flow/components/commands.js.flow +2 -1
- package/lib/parsers/flow/components/componentsUtils.js +10 -0
- package/lib/parsers/flow/components/componentsUtils.js.flow +11 -1
- package/lib/parsers/flow/components/events.js.flow +1 -1
- package/lib/parsers/flow/components/extends.js.flow +1 -1
- package/lib/parsers/flow/components/index.js +16 -20
- package/lib/parsers/flow/components/index.js.flow +8 -7
- package/lib/parsers/flow/components/options.js.flow +1 -1
- package/lib/parsers/flow/components/props.js.flow +1 -1
- package/lib/parsers/flow/modules/__test_fixtures__/failures.js +54 -0
- package/lib/parsers/flow/modules/__test_fixtures__/failures.js.flow +56 -0
- package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js +64 -1
- package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js.flow +66 -1
- package/lib/parsers/flow/modules/index.js +112 -48
- package/lib/parsers/flow/modules/index.js.flow +115 -44
- package/lib/parsers/flow/parser.d.ts +10 -0
- package/lib/parsers/flow/parser.js +173 -32
- package/lib/parsers/flow/parser.js.flow +201 -24
- package/lib/parsers/flow/utils.js +33 -57
- package/lib/parsers/flow/utils.js.flow +37 -60
- package/lib/parsers/parser.d.ts +17 -0
- package/lib/parsers/parser.js.flow +124 -17
- package/lib/parsers/parserMock.js +101 -30
- package/lib/parsers/parserMock.js.flow +139 -24
- package/lib/parsers/parsers-commons.js +121 -119
- package/lib/parsers/parsers-commons.js.flow +136 -131
- package/lib/parsers/parsers-primitives.js +75 -12
- package/lib/parsers/parsers-primitives.js.flow +92 -13
- package/lib/parsers/schema/index.d.ts +10 -0
- package/lib/parsers/{typescript/components/schema.js.flow → schema.js.flow} +1 -1
- package/lib/parsers/typescript/Visitor.js +42 -0
- package/lib/parsers/typescript/Visitor.js.flow +47 -0
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js +22 -0
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow +22 -0
- package/lib/parsers/typescript/components/commands.js +3 -0
- package/lib/parsers/typescript/components/commands.js.flow +2 -1
- package/lib/parsers/typescript/components/componentsUtils.js +5 -0
- package/lib/parsers/typescript/components/componentsUtils.js.flow +6 -1
- package/lib/parsers/typescript/components/events.js.flow +1 -1
- package/lib/parsers/typescript/components/extends.js.flow +1 -1
- package/lib/parsers/typescript/components/index.js +15 -19
- package/lib/parsers/typescript/components/index.js.flow +8 -7
- package/lib/parsers/typescript/components/options.js.flow +1 -1
- package/lib/parsers/typescript/components/props.js.flow +1 -1
- package/lib/parsers/typescript/modules/__test_fixtures__/failures.js +52 -0
- package/lib/parsers/typescript/modules/__test_fixtures__/failures.js.flow +54 -0
- package/lib/parsers/typescript/modules/__test_fixtures__/fixtures.js +142 -0
- package/lib/parsers/typescript/modules/__test_fixtures__/fixtures.js.flow +146 -0
- package/lib/parsers/typescript/modules/index.js +276 -110
- package/lib/parsers/typescript/modules/index.js.flow +237 -68
- package/lib/parsers/typescript/parser.d.ts +10 -0
- package/lib/parsers/typescript/parser.js +175 -25
- package/lib/parsers/typescript/parser.js.flow +184 -26
- package/lib/parsers/typescript/utils.js +40 -51
- package/lib/parsers/typescript/utils.js.flow +44 -55
- package/lib/parsers/utils.js +0 -125
- package/lib/parsers/utils.js.flow +3 -70
- package/package.json +4 -1
- package/lib/parsers/flow/components/schema.js +0 -106
- package/lib/parsers/flow/components/schema.js.flow +0 -62
- package/lib/parsers/flow/index.js +0 -80
- package/lib/parsers/flow/index.js.flow +0 -85
- package/lib/parsers/typescript/index.js +0 -85
- package/lib/parsers/typescript/index.js.flow +0 -94
- /package/lib/parsers/{typescript/components/schema.js → schema.js} +0 -0
|
@@ -149,6 +149,56 @@ export interface Spec2 extends TurboModule {
|
|
|
149
149
|
readonly getSth: (a: number | null | undefined) => void;
|
|
150
150
|
}
|
|
151
151
|
`;
|
|
152
|
+
const EMPTY_ENUM_NATIVE_MODULE = `
|
|
153
|
+
/**
|
|
154
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
155
|
+
*
|
|
156
|
+
* This source code is licensed under the MIT license found in the
|
|
157
|
+
* LICENSE file in the root directory of this source tree.
|
|
158
|
+
*
|
|
159
|
+
* @format
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
|
163
|
+
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
|
164
|
+
|
|
165
|
+
export enum SomeEnum {
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface Spec extends TurboModule {
|
|
169
|
+
readonly getEnums: (a: SomeEnum) => string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
173
|
+
'EmptyEnumNativeModule',
|
|
174
|
+
);
|
|
175
|
+
`;
|
|
176
|
+
const MIXED_VALUES_ENUM_NATIVE_MODULE = `
|
|
177
|
+
/**
|
|
178
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
179
|
+
*
|
|
180
|
+
* This source code is licensed under the MIT license found in the
|
|
181
|
+
* LICENSE file in the root directory of this source tree.
|
|
182
|
+
*
|
|
183
|
+
* @format
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
|
187
|
+
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
|
188
|
+
|
|
189
|
+
export enum SomeEnum {
|
|
190
|
+
NUM = 1,
|
|
191
|
+
STR = 'str',
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface Spec extends TurboModule {
|
|
195
|
+
readonly getEnums: (a: SomeEnum) => string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
199
|
+
'MixedValuesEnumNativeModule',
|
|
200
|
+
);
|
|
201
|
+
`;
|
|
152
202
|
module.exports = {
|
|
153
203
|
NATIVE_MODULES_WITH_UNNAMED_PARAMS,
|
|
154
204
|
NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE,
|
|
@@ -157,4 +207,6 @@ module.exports = {
|
|
|
157
207
|
TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT,
|
|
158
208
|
NATIVE_MODULES_WITH_NOT_ONLY_METHODS,
|
|
159
209
|
TWO_NATIVE_EXTENDING_TURBO_MODULE,
|
|
210
|
+
EMPTY_ENUM_NATIVE_MODULE,
|
|
211
|
+
MIXED_VALUES_ENUM_NATIVE_MODULE,
|
|
160
212
|
};
|
|
@@ -156,6 +156,58 @@ export interface Spec2 extends TurboModule {
|
|
|
156
156
|
}
|
|
157
157
|
`;
|
|
158
158
|
|
|
159
|
+
const EMPTY_ENUM_NATIVE_MODULE = `
|
|
160
|
+
/**
|
|
161
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
162
|
+
*
|
|
163
|
+
* This source code is licensed under the MIT license found in the
|
|
164
|
+
* LICENSE file in the root directory of this source tree.
|
|
165
|
+
*
|
|
166
|
+
* @format
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
|
170
|
+
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
|
171
|
+
|
|
172
|
+
export enum SomeEnum {
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface Spec extends TurboModule {
|
|
176
|
+
readonly getEnums: (a: SomeEnum) => string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
180
|
+
'EmptyEnumNativeModule',
|
|
181
|
+
);
|
|
182
|
+
`;
|
|
183
|
+
|
|
184
|
+
const MIXED_VALUES_ENUM_NATIVE_MODULE = `
|
|
185
|
+
/**
|
|
186
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
187
|
+
*
|
|
188
|
+
* This source code is licensed under the MIT license found in the
|
|
189
|
+
* LICENSE file in the root directory of this source tree.
|
|
190
|
+
*
|
|
191
|
+
* @format
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
|
195
|
+
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
|
196
|
+
|
|
197
|
+
export enum SomeEnum {
|
|
198
|
+
NUM = 1,
|
|
199
|
+
STR = 'str',
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface Spec extends TurboModule {
|
|
203
|
+
readonly getEnums: (a: SomeEnum) => string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
207
|
+
'MixedValuesEnumNativeModule',
|
|
208
|
+
);
|
|
209
|
+
`;
|
|
210
|
+
|
|
159
211
|
module.exports = {
|
|
160
212
|
NATIVE_MODULES_WITH_UNNAMED_PARAMS,
|
|
161
213
|
NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE,
|
|
@@ -164,4 +216,6 @@ module.exports = {
|
|
|
164
216
|
TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT,
|
|
165
217
|
NATIVE_MODULES_WITH_NOT_ONLY_METHODS,
|
|
166
218
|
TWO_NATIVE_EXTENDING_TURBO_MODULE,
|
|
219
|
+
EMPTY_ENUM_NATIVE_MODULE,
|
|
220
|
+
MIXED_VALUES_ENUM_NATIVE_MODULE,
|
|
167
221
|
};
|
|
@@ -188,6 +188,92 @@ export interface Spec extends TurboModule {
|
|
|
188
188
|
|
|
189
189
|
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
190
190
|
|
|
191
|
+
`;
|
|
192
|
+
const NATIVE_MODULE_WITH_NESTED_INTERFACES = `
|
|
193
|
+
/**
|
|
194
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
195
|
+
*
|
|
196
|
+
* This source code is licensed under the MIT license found in the
|
|
197
|
+
* LICENSE file in the root directory of this source tree.
|
|
198
|
+
*
|
|
199
|
+
* @format
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
import type {TurboModule} from '../RCTExport';
|
|
204
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
205
|
+
|
|
206
|
+
interface Bar {
|
|
207
|
+
z: number
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
interface Base1 {
|
|
211
|
+
bar1: Bar,
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
interface Base2 {
|
|
215
|
+
bar2: Bar,
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
interface Base3 extends Base2 {
|
|
219
|
+
bar3: Bar,
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
interface Foo extends Base1, Base3 {
|
|
223
|
+
bar4: Bar,
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export interface Spec extends TurboModule {
|
|
227
|
+
// Exported methods.
|
|
228
|
+
foo1: (x: Foo) => Foo;
|
|
229
|
+
foo2: (x: Foo) => void;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
233
|
+
|
|
234
|
+
`;
|
|
235
|
+
const NATIVE_MODULE_WITH_INTERSECTION_TYPES = `
|
|
236
|
+
/**
|
|
237
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
238
|
+
*
|
|
239
|
+
* This source code is licensed under the MIT license found in the
|
|
240
|
+
* LICENSE file in the root directory of this source tree.
|
|
241
|
+
*
|
|
242
|
+
* @format
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
import type {TurboModule} from '../RCTExport';
|
|
247
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
248
|
+
|
|
249
|
+
type Bar = {
|
|
250
|
+
z: number
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
type Base1 = {
|
|
254
|
+
bar1: Bar,
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
type Base2 = {
|
|
258
|
+
bar2: Bar,
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
type Base3 = Base2 & {
|
|
262
|
+
bar3: Bar,
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
type Foo = Base1 & Base3 & {
|
|
266
|
+
bar4: Bar,
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export interface Spec extends TurboModule {
|
|
270
|
+
// Exported methods.
|
|
271
|
+
foo1: (x: Foo) => Foo;
|
|
272
|
+
foo2: (x: Foo) => void;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
276
|
+
|
|
191
277
|
`;
|
|
192
278
|
const NATIVE_MODULE_WITH_FLOAT_AND_INT32 = `
|
|
193
279
|
/**
|
|
@@ -247,6 +333,58 @@ export interface Spec extends TurboModule {
|
|
|
247
333
|
readonly getUnsafeObject: (o: UnsafeObject) => UnsafeObject;
|
|
248
334
|
}
|
|
249
335
|
|
|
336
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
337
|
+
`;
|
|
338
|
+
const NATIVE_MODULE_WITH_PARTIALS = `
|
|
339
|
+
/**
|
|
340
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
341
|
+
*
|
|
342
|
+
* This source code is licensed under the MIT license found in the
|
|
343
|
+
* LICENSE file in the root directory of this source tree.
|
|
344
|
+
*
|
|
345
|
+
* @format
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
|
349
|
+
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
|
350
|
+
|
|
351
|
+
export type SomeObj = {
|
|
352
|
+
a: string,
|
|
353
|
+
b?: boolean,
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
export interface Spec extends TurboModule {
|
|
357
|
+
getSomeObj: () => SomeObj;
|
|
358
|
+
getPartialSomeObj: () => Partial<SomeObj>;
|
|
359
|
+
getSomeObjFromPartialSomeObj: (value: Partial<SomeObj>) => SomeObj;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
363
|
+
`;
|
|
364
|
+
const NATIVE_MODULE_WITH_PARTIALS_COMPLEX = `
|
|
365
|
+
/**
|
|
366
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
367
|
+
*
|
|
368
|
+
* This source code is licensed under the MIT license found in the
|
|
369
|
+
* LICENSE file in the root directory of this source tree.
|
|
370
|
+
*
|
|
371
|
+
* @format
|
|
372
|
+
*/
|
|
373
|
+
|
|
374
|
+
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
|
375
|
+
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
|
376
|
+
|
|
377
|
+
export type SomeObj = {
|
|
378
|
+
a: string,
|
|
379
|
+
b?: boolean,
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
export type PartialSomeObj = Partial<SomeObj>;
|
|
383
|
+
|
|
384
|
+
export interface Spec extends TurboModule {
|
|
385
|
+
getPartialPartial: (value1: Partial<SomeObj>, value2: PartialSomeObj) => SomeObj;
|
|
386
|
+
}
|
|
387
|
+
|
|
250
388
|
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
251
389
|
`;
|
|
252
390
|
const NATIVE_MODULE_WITH_ROOT_TAG = `
|
|
@@ -678,11 +816,15 @@ module.exports = {
|
|
|
678
816
|
NATIVE_MODULE_WITH_FLOAT_AND_INT32,
|
|
679
817
|
NATIVE_MODULE_WITH_ALIASES,
|
|
680
818
|
NATIVE_MODULE_WITH_NESTED_ALIASES,
|
|
819
|
+
NATIVE_MODULE_WITH_NESTED_INTERFACES,
|
|
820
|
+
NATIVE_MODULE_WITH_INTERSECTION_TYPES,
|
|
681
821
|
NATIVE_MODULE_WITH_PROMISE,
|
|
682
822
|
NATIVE_MODULE_WITH_COMPLEX_OBJECTS,
|
|
683
823
|
NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY,
|
|
684
824
|
NATIVE_MODULE_WITH_SIMPLE_OBJECT,
|
|
685
825
|
NATIVE_MODULE_WITH_UNSAFE_OBJECT,
|
|
826
|
+
NATIVE_MODULE_WITH_PARTIALS,
|
|
827
|
+
NATIVE_MODULE_WITH_PARTIALS_COMPLEX,
|
|
686
828
|
NATIVE_MODULE_WITH_ROOT_TAG,
|
|
687
829
|
NATIVE_MODULE_WITH_NULLABLE_PARAM,
|
|
688
830
|
NATIVE_MODULE_WITH_BASIC_ARRAY,
|
|
@@ -195,6 +195,94 @@ export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
|
195
195
|
|
|
196
196
|
`;
|
|
197
197
|
|
|
198
|
+
const NATIVE_MODULE_WITH_NESTED_INTERFACES = `
|
|
199
|
+
/**
|
|
200
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
201
|
+
*
|
|
202
|
+
* This source code is licensed under the MIT license found in the
|
|
203
|
+
* LICENSE file in the root directory of this source tree.
|
|
204
|
+
*
|
|
205
|
+
* @format
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
import type {TurboModule} from '../RCTExport';
|
|
210
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
211
|
+
|
|
212
|
+
interface Bar {
|
|
213
|
+
z: number
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
interface Base1 {
|
|
217
|
+
bar1: Bar,
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
interface Base2 {
|
|
221
|
+
bar2: Bar,
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
interface Base3 extends Base2 {
|
|
225
|
+
bar3: Bar,
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
interface Foo extends Base1, Base3 {
|
|
229
|
+
bar4: Bar,
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export interface Spec extends TurboModule {
|
|
233
|
+
// Exported methods.
|
|
234
|
+
foo1: (x: Foo) => Foo;
|
|
235
|
+
foo2: (x: Foo) => void;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
239
|
+
|
|
240
|
+
`;
|
|
241
|
+
|
|
242
|
+
const NATIVE_MODULE_WITH_INTERSECTION_TYPES = `
|
|
243
|
+
/**
|
|
244
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
245
|
+
*
|
|
246
|
+
* This source code is licensed under the MIT license found in the
|
|
247
|
+
* LICENSE file in the root directory of this source tree.
|
|
248
|
+
*
|
|
249
|
+
* @format
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
import type {TurboModule} from '../RCTExport';
|
|
254
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
255
|
+
|
|
256
|
+
type Bar = {
|
|
257
|
+
z: number
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
type Base1 = {
|
|
261
|
+
bar1: Bar,
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
type Base2 = {
|
|
265
|
+
bar2: Bar,
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
type Base3 = Base2 & {
|
|
269
|
+
bar3: Bar,
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
type Foo = Base1 & Base3 & {
|
|
273
|
+
bar4: Bar,
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export interface Spec extends TurboModule {
|
|
277
|
+
// Exported methods.
|
|
278
|
+
foo1: (x: Foo) => Foo;
|
|
279
|
+
foo2: (x: Foo) => void;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
283
|
+
|
|
284
|
+
`;
|
|
285
|
+
|
|
198
286
|
const NATIVE_MODULE_WITH_FLOAT_AND_INT32 = `
|
|
199
287
|
/**
|
|
200
288
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -258,6 +346,60 @@ export interface Spec extends TurboModule {
|
|
|
258
346
|
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
259
347
|
`;
|
|
260
348
|
|
|
349
|
+
const NATIVE_MODULE_WITH_PARTIALS = `
|
|
350
|
+
/**
|
|
351
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
352
|
+
*
|
|
353
|
+
* This source code is licensed under the MIT license found in the
|
|
354
|
+
* LICENSE file in the root directory of this source tree.
|
|
355
|
+
*
|
|
356
|
+
* @format
|
|
357
|
+
*/
|
|
358
|
+
|
|
359
|
+
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
|
360
|
+
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
|
361
|
+
|
|
362
|
+
export type SomeObj = {
|
|
363
|
+
a: string,
|
|
364
|
+
b?: boolean,
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
export interface Spec extends TurboModule {
|
|
368
|
+
getSomeObj: () => SomeObj;
|
|
369
|
+
getPartialSomeObj: () => Partial<SomeObj>;
|
|
370
|
+
getSomeObjFromPartialSomeObj: (value: Partial<SomeObj>) => SomeObj;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
374
|
+
`;
|
|
375
|
+
|
|
376
|
+
const NATIVE_MODULE_WITH_PARTIALS_COMPLEX = `
|
|
377
|
+
/**
|
|
378
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
379
|
+
*
|
|
380
|
+
* This source code is licensed under the MIT license found in the
|
|
381
|
+
* LICENSE file in the root directory of this source tree.
|
|
382
|
+
*
|
|
383
|
+
* @format
|
|
384
|
+
*/
|
|
385
|
+
|
|
386
|
+
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
|
387
|
+
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
|
388
|
+
|
|
389
|
+
export type SomeObj = {
|
|
390
|
+
a: string,
|
|
391
|
+
b?: boolean,
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
export type PartialSomeObj = Partial<SomeObj>;
|
|
395
|
+
|
|
396
|
+
export interface Spec extends TurboModule {
|
|
397
|
+
getPartialPartial: (value1: Partial<SomeObj>, value2: PartialSomeObj) => SomeObj;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
401
|
+
`;
|
|
402
|
+
|
|
261
403
|
const NATIVE_MODULE_WITH_ROOT_TAG = `
|
|
262
404
|
/**
|
|
263
405
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -704,11 +846,15 @@ module.exports = {
|
|
|
704
846
|
NATIVE_MODULE_WITH_FLOAT_AND_INT32,
|
|
705
847
|
NATIVE_MODULE_WITH_ALIASES,
|
|
706
848
|
NATIVE_MODULE_WITH_NESTED_ALIASES,
|
|
849
|
+
NATIVE_MODULE_WITH_NESTED_INTERFACES,
|
|
850
|
+
NATIVE_MODULE_WITH_INTERSECTION_TYPES,
|
|
707
851
|
NATIVE_MODULE_WITH_PROMISE,
|
|
708
852
|
NATIVE_MODULE_WITH_COMPLEX_OBJECTS,
|
|
709
853
|
NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY,
|
|
710
854
|
NATIVE_MODULE_WITH_SIMPLE_OBJECT,
|
|
711
855
|
NATIVE_MODULE_WITH_UNSAFE_OBJECT,
|
|
856
|
+
NATIVE_MODULE_WITH_PARTIALS,
|
|
857
|
+
NATIVE_MODULE_WITH_PARTIALS_COMPLEX,
|
|
712
858
|
NATIVE_MODULE_WITH_ROOT_TAG,
|
|
713
859
|
NATIVE_MODULE_WITH_NULLABLE_PARAM,
|
|
714
860
|
NATIVE_MODULE_WITH_BASIC_ARRAY,
|