@react-native-windows/codegen 0.0.0-canary.10 → 0.0.0-canary.101

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +884 -4
  2. package/README.md +1 -1
  3. package/bin.js +0 -0
  4. package/lib-commonjs/Cli.d.ts +7 -0
  5. package/lib-commonjs/Cli.js +103 -0
  6. package/lib-commonjs/Cli.js.map +1 -0
  7. package/lib-commonjs/generators/AliasGen.d.ts +12 -0
  8. package/lib-commonjs/generators/AliasGen.js +113 -0
  9. package/lib-commonjs/generators/AliasGen.js.map +1 -0
  10. package/lib-commonjs/generators/AliasManaging.d.ts +15 -0
  11. package/lib-commonjs/generators/AliasManaging.js +49 -0
  12. package/lib-commonjs/generators/AliasManaging.js.map +1 -0
  13. package/lib-commonjs/generators/GenerateComponentWindows.d.ts +13 -0
  14. package/lib-commonjs/generators/GenerateComponentWindows.js +337 -0
  15. package/lib-commonjs/generators/GenerateComponentWindows.js.map +1 -0
  16. package/lib-commonjs/generators/GenerateNM2.d.ts +15 -0
  17. package/lib-commonjs/generators/GenerateNM2.js +142 -0
  18. package/lib-commonjs/generators/GenerateNM2.js.map +1 -0
  19. package/lib-commonjs/generators/GenerateTypeScript.d.ts +11 -0
  20. package/lib-commonjs/generators/GenerateTypeScript.js +166 -0
  21. package/lib-commonjs/generators/GenerateTypeScript.js.map +1 -0
  22. package/lib-commonjs/generators/ObjectTypes.d.ts +13 -0
  23. package/lib-commonjs/generators/ObjectTypes.js +76 -0
  24. package/lib-commonjs/generators/ObjectTypes.js.map +1 -0
  25. package/lib-commonjs/generators/ParamTypes.d.ts +13 -0
  26. package/lib-commonjs/generators/ParamTypes.js +179 -0
  27. package/lib-commonjs/generators/ParamTypes.js.map +1 -0
  28. package/lib-commonjs/generators/PropObjectTypes.d.ts +18 -0
  29. package/lib-commonjs/generators/PropObjectTypes.js +217 -0
  30. package/lib-commonjs/generators/PropObjectTypes.js.map +1 -0
  31. package/lib-commonjs/generators/ReturnTypes.d.ts +10 -0
  32. package/lib-commonjs/generators/ReturnTypes.js +29 -0
  33. package/lib-commonjs/generators/ReturnTypes.js.map +1 -0
  34. package/lib-commonjs/generators/ValidateConstants.d.ts +8 -0
  35. package/lib-commonjs/generators/ValidateConstants.js +38 -0
  36. package/lib-commonjs/generators/ValidateConstants.js.map +1 -0
  37. package/lib-commonjs/generators/ValidateMethods.d.ts +14 -0
  38. package/lib-commonjs/generators/ValidateMethods.js +103 -0
  39. package/lib-commonjs/generators/ValidateMethods.js.map +1 -0
  40. package/lib-commonjs/index.d.ts +39 -0
  41. package/lib-commonjs/index.js +227 -0
  42. package/lib-commonjs/index.js.map +1 -0
  43. package/package.json +41 -21
  44. package/src/Cli.ts +68 -223
  45. package/src/generators/AliasGen.ts +186 -0
  46. package/src/generators/AliasManaging.ts +75 -0
  47. package/src/generators/GenerateComponentWindows.ts +393 -0
  48. package/src/generators/GenerateNM2.ts +138 -295
  49. package/src/generators/GenerateTypeScript.ts +247 -0
  50. package/src/generators/ObjectTypes.ts +131 -0
  51. package/src/generators/ParamTypes.ts +382 -0
  52. package/src/generators/PropObjectTypes.ts +233 -0
  53. package/src/generators/ReturnTypes.ts +70 -0
  54. package/src/generators/ValidateConstants.ts +50 -0
  55. package/src/generators/ValidateMethods.ts +258 -0
  56. package/src/index.ts +416 -0
  57. package/.eslintrc.js +0 -4
  58. package/.vscode/launch.json +0 -23
  59. package/CHANGELOG.json +0 -613
  60. package/jest.config.js +0 -1
  61. package/tsconfig.json +0 -5
package/src/Cli.ts CHANGED
@@ -6,14 +6,7 @@
6
6
  */
7
7
 
8
8
  import yargs from 'yargs';
9
- import path from 'path';
10
- import fs from 'fs';
11
- import globby from 'globby';
12
- import {createNM2Generator} from './generators/GenerateNM2';
13
- // @ts-ignore
14
- import {parseFile} from 'react-native-tscodegen/lib/rncodegen/src/parsers/flow';
15
- // @ts-ignore
16
- import schemaValidator from 'react-native-tscodegen/lib/rncodegen/src/schemaValidator';
9
+ import {CodeGenOptions, runCodeGen} from './index';
17
10
 
18
11
  const argv = yargs.options({
19
12
  file: {
@@ -21,12 +14,39 @@ const argv = yargs.options({
21
14
  describe: 'file which contains spec',
22
15
  },
23
16
  files: {
24
- type: 'array',
17
+ type: 'string',
18
+ array: true,
25
19
  describe: 'glob patterns for files which contains specs',
26
20
  },
21
+ modulesTypeScriptTypes: {
22
+ type: 'boolean',
23
+ describe: 'generate turbo module definition files in TypeScript',
24
+ default: false,
25
+ },
26
+ modulesCxx: {
27
+ type: 'boolean',
28
+ describe: 'generate C++ JSI turbo module spec files',
29
+ default: false,
30
+ },
31
+ modulesWindows: {
32
+ type: 'boolean',
33
+ describe: 'generate turbo module spec files for REACT_MODULE',
34
+ default: false,
35
+ },
36
+ methodOnly: {
37
+ type: 'boolean',
38
+ describe: 'generate only method metadata in C++ turbo module spec',
39
+ default: false,
40
+ },
41
+ outputDirectory: {
42
+ type: 'string',
43
+ describe: 'output directory',
44
+ default: 'codegen',
45
+ },
27
46
  test: {
28
47
  type: 'boolean',
29
48
  describe: 'Verify that the generated output is unchanged',
49
+ default: false,
30
50
  },
31
51
  namespace: {
32
52
  type: 'string',
@@ -38,226 +58,51 @@ const argv = yargs.options({
38
58
  required: true,
39
59
  describe: 'Used for part of the path generated within the codegen dir',
40
60
  },
41
- }).argv;
42
-
43
- import {SchemaType} from 'react-native-tscodegen';
44
-
45
- interface Options {
46
- libraryName: string;
47
- schema: SchemaType;
48
- outputDirectory: string;
49
- moduleSpecName: string;
50
- }
51
-
52
- interface Config {
53
- generators: any[] /*Generators[]*/;
54
- test?: boolean;
55
- }
56
-
57
- /*
58
- const GENERATORS = {
59
- descriptors: [generateComponentDescriptorH.generate],
60
- events: [
61
- generateEventEmitterCpp.generate,
62
- generateEventEmitterH.generate,
63
- generateModuleHObjCpp.generate,
64
- generateModuleMm.generate,
65
- ],
66
- props: [
67
- generateComponentHObjCpp.generate,
68
- generatePropsCpp.generate,
69
- generatePropsH.generate,
70
- generatePropsJavaInterface.generate,
71
- generatePropsJavaDelegate.generate,
72
- ],
73
- modules: [generateModuleCpp.generate, generateModuleH.generate],
74
- tests: [generateTests.generate],
75
- 'shadow-nodes': [
76
- generateShadowNodeCpp.generate,
77
- generateShadowNodeH.generate,
78
- ],
79
- };
80
- */
81
-
82
- function normalizeFileMap(
83
- map: Map<string, string>,
84
- outputDir: string,
85
- outMap: Map<string, string>,
86
- ): void {
87
- for (const [fileName, contents] of map) {
88
- const location = path.join(outputDir, fileName);
89
- outMap.set(path.normalize(location), contents);
90
- }
91
- }
92
-
93
- function checkFilesForChanges(
94
- map: Map<string, string>,
95
- outputDir: string,
96
- ): boolean {
97
- let hasChanges = false;
98
-
99
- const allExistingFiles = globby
100
- .sync(`${outputDir}/**`)
101
- .map(_ => path.normalize(_))
102
- .sort();
103
- const allGeneratedFiles = [...map.keys()].map(_ => path.normalize(_)).sort();
104
-
105
- if (
106
- allExistingFiles.length !== allGeneratedFiles.length ||
107
- !allExistingFiles.every((val, index) => val === allGeneratedFiles[index])
108
- )
109
- return true;
110
-
111
- for (const [fileName, contents] of map) {
112
- if (!fs.existsSync(fileName)) {
113
- hasChanges = true;
114
- continue;
115
- }
116
-
117
- const currentContents = fs.readFileSync(fileName, 'utf8');
118
- if (currentContents !== contents) {
119
- console.error(`- ${fileName} has changed`);
120
- hasChanges = true;
121
- continue;
122
- }
123
- }
124
-
125
- return hasChanges;
126
- }
127
-
128
- function writeMapToFiles(map: Map<string, string>, outputDir: string) {
129
- let success = true;
130
-
131
- // This ensures that we delete any generated files from modules that have been deleted
132
- const allExistingFiles = globby.sync(`${outputDir}/**`);
133
- allExistingFiles.forEach(existingFile => {
134
- if (!map.has(path.normalize(existingFile))) {
135
- fs.unlinkSync(existingFile);
136
- }
137
- });
138
-
139
- for (const [fileName, contents] of map) {
140
- try {
141
- fs.mkdirSync(path.dirname(fileName), {recursive: true});
142
-
143
- if (fs.existsSync(fileName)) {
144
- const currentContents = fs.readFileSync(fileName, 'utf8');
145
- // Don't update the files if there are no changes as this breaks incremental builds
146
- if (currentContents === contents) {
147
- continue;
148
- }
149
- }
150
-
151
- fs.writeFileSync(fileName, contents);
152
- } catch (error) {
153
- success = false;
154
- console.error(`Failed to write ${fileName} to ${fileName}`, error);
155
- }
156
- }
157
-
158
- return success;
159
- }
160
-
161
- function combineSchemas(files: string[]): SchemaType {
162
- return files.reduce(
163
- (merged, filename) => {
164
- const contents = fs.readFileSync(filename, 'utf8');
165
- if (
166
- contents &&
167
- (/export\s+default\s+\(?codegenNativeComponent</.test(contents) ||
168
- contents.includes('extends TurboModule'))
169
- ) {
170
- const schema = parseFile(filename);
171
-
172
- if (schema && schema.modules) {
173
- merged.modules = {...merged.modules, ...schema.modules};
174
- }
175
- }
176
- return merged;
177
- },
178
- {modules: {}},
179
- );
180
- }
181
-
182
- function generate(
183
- {libraryName, schema, outputDirectory, moduleSpecName}: Options,
184
- {/*generators,*/ test}: Config,
185
- ): boolean {
186
- schemaValidator.validate(schema);
187
-
188
- const componentOutputdir = path.join(
189
- outputDirectory,
190
- 'react/components',
191
- libraryName,
192
- );
193
-
194
- const generatedFiles = new Map<string, string>();
195
-
196
- generatedFiles.set(
197
- path.join(outputDirectory, '.clang-format'),
198
- 'DisableFormat: true\nSortIncludes: false',
199
- );
200
-
201
- const generateNM2 = createNM2Generator({namespace: argv.namespace});
202
- const generatorPropsH = require('react-native-tscodegen/lib/rncodegen/src/generators/components/GeneratePropsH')
203
- .generate;
204
- const generatorPropsCPP = require('react-native-tscodegen/lib/rncodegen/src/generators/components/GeneratePropsCPP')
205
- .generate;
206
- const generatorShadowNodeH = require('react-native-tscodegen/lib/rncodegen/src/generators/components/GenerateShadowNodeH')
207
- .generate;
208
- const generatorShadowNodeCPP = require('react-native-tscodegen/lib/rncodegen/src/generators/components/GenerateShadowNodeCPP')
209
- .generate;
210
- const generatorComponentDescriptorH = require('react-native-tscodegen/lib/rncodegen/src/generators/components/GenerateComponentDescriptorH')
211
- .generate;
212
- const generatorEventEmitterH = require('react-native-tscodegen/lib/rncodegen/src/generators/components/GenerateEventEmitterH')
213
- .generate;
214
-
215
- normalizeFileMap(
216
- generateNM2(libraryName, schema, moduleSpecName),
217
- outputDirectory,
218
- generatedFiles,
219
- );
220
-
221
- const componentGenerators = [
222
- generatorPropsH,
223
- generatorPropsCPP,
224
- generatorShadowNodeH,
225
- generatorShadowNodeCPP,
226
- generatorComponentDescriptorH,
227
- generatorEventEmitterH,
228
- ];
229
-
230
- componentGenerators.forEach(generator => {
231
- normalizeFileMap(
232
- generator(libraryName, schema, moduleSpecName),
233
- componentOutputdir,
234
- generatedFiles,
235
- );
236
- });
237
-
238
- if (test === true) {
239
- return checkFilesForChanges(generatedFiles, outputDirectory);
61
+ cppStringType: {
62
+ choices: ['std::string', 'std::wstring'],
63
+ describe:
64
+ 'C++ string type in generated code, should be "std::string" or "std::wstring"',
65
+ default: 'std::string',
66
+ },
67
+ separateDataTypes: {
68
+ type: 'boolean',
69
+ describe: 'generate data types in a separate file',
70
+ default: false,
71
+ },
72
+ componentsWindows: {
73
+ type: 'boolean',
74
+ describe: 'generate component cpp files for custom native components',
75
+ default: false,
76
+ },
77
+ internalComponents: {
78
+ type: 'boolean',
79
+ describe: 'generate non-ABI cpp/h for internal usage of built in native components [Only used within RNW itself]',
80
+ default: false,
81
+ hidden: true,
240
82
  }
241
-
242
- return writeMapToFiles(generatedFiles, outputDirectory);
243
- }
83
+ }).argv;
244
84
 
245
85
  if ((argv.file && argv.files) || (!argv.file && !argv.files)) {
246
86
  console.error('You must specify either --file or --files.');
247
87
  process.exit(1);
248
88
  }
249
89
 
250
- let schema: SchemaType;
251
- if (argv.file) {
252
- schema = parseFile(argv.file);
253
- } else {
254
- schema = combineSchemas(globby.sync(argv.files as string[]));
90
+ if (
91
+ argv.cppStringType !== 'std::string' &&
92
+ argv.cppStringType !== 'std::wstring'
93
+ ) {
94
+ console.error('cppStringType should be "std::string" or "std::wstring".');
95
+ process.exit(1);
255
96
  }
256
97
 
257
- const libraryName = argv.libraryName;
258
- const moduleSpecName = 'moduleSpecName';
259
- const outputDirectory = 'codegen';
260
- generate(
261
- {libraryName, schema, outputDirectory, moduleSpecName},
262
- {generators: [], test: false},
263
- );
98
+ // type casting is necessary here because
99
+ // cppStringType does not become union of string literals
100
+ // until yargs.options get improved in the future
101
+ const changesNecessary = runCodeGen(<CodeGenOptions>argv);
102
+
103
+ if (argv.test && changesNecessary) {
104
+ console.error(
105
+ 'There is a change in the output of codegen. Rerun "npx @react-native-community/cli codegen-windows" to regenerate.',
106
+ );
107
+ process.exit(2);
108
+ }
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ import type {
10
+ NativeModuleBaseTypeAnnotation,
11
+ NativeModuleObjectTypeAnnotation,
12
+ NamedShape,
13
+ Nullable,
14
+ } from '@react-native/codegen/lib/CodegenSchema';
15
+ import {AliasMap, getAliasCppName} from './AliasManaging';
16
+ import {CppCodegenOptions, translateField} from './ObjectTypes';
17
+
18
+ function translateObjectMembersDefinition(
19
+ type: NativeModuleObjectTypeAnnotation,
20
+ aliases: AliasMap,
21
+ baseAliasName: string,
22
+ prefix: string,
23
+ options: CppCodegenOptions,
24
+ ) {
25
+ return type.properties
26
+ .map((prop: NamedShape<Nullable<NativeModuleBaseTypeAnnotation>>) => {
27
+ let propType = prop.typeAnnotation;
28
+ if (prop.optional && propType.type !== 'NullableTypeAnnotation') {
29
+ propType = {type: 'NullableTypeAnnotation', typeAnnotation: propType};
30
+ }
31
+ return `${prefix}${translateField(
32
+ propType,
33
+ aliases,
34
+ `${baseAliasName}_${prop.name}`,
35
+ options,
36
+ )} ${prop.name};`;
37
+ })
38
+ .join('\n');
39
+ }
40
+
41
+ function translateObjectMembersReflection(
42
+ type: NativeModuleObjectTypeAnnotation,
43
+ aliasCppName: string,
44
+ prefix: string,
45
+ ) {
46
+ return type.properties
47
+ .map((prop: NamedShape<Nullable<NativeModuleBaseTypeAnnotation>>) => {
48
+ return `${prefix}{L"${prop.name}", &${aliasCppName}::${prop.name}},`;
49
+ })
50
+ .join('\n');
51
+ }
52
+
53
+ export function createAliasMap(nativeModuleAliases: {
54
+ [name: string]: NativeModuleObjectTypeAnnotation;
55
+ }): AliasMap {
56
+ const aliases: AliasMap = {types: {}, jobs: Object.keys(nativeModuleAliases)};
57
+ for (const aliasName of aliases.jobs) {
58
+ aliases.types[aliasName] = nativeModuleAliases[aliasName];
59
+ }
60
+ return aliases;
61
+ }
62
+
63
+ interface AliasCode {
64
+ definition: string;
65
+ reflection: string;
66
+ }
67
+
68
+ interface AliasCodeMap {
69
+ [name: string]: AliasCode;
70
+ }
71
+
72
+ function getArrayTypeName(
73
+ type: Nullable<NativeModuleBaseTypeAnnotation>): string {
74
+ if (type.type === 'ArrayTypeAnnotation' && type.elementType?.type === 'TypeAliasTypeAnnotation') {
75
+ return type.elementType.name;
76
+ }
77
+
78
+ return '';
79
+ }
80
+
81
+ function checkTypes(
82
+ aliases: AliasMap,
83
+ type: NativeModuleObjectTypeAnnotation,
84
+ aliasOrder: string[]): void {
85
+ for (const prop of type.properties) {
86
+ const propType = prop.typeAnnotation;
87
+ let propName = '';
88
+
89
+ if (propType.type === 'TypeAliasTypeAnnotation') {
90
+ propName = propType.name;
91
+ }
92
+
93
+ if (propType.type === 'ArrayTypeAnnotation') {
94
+ propName = getArrayTypeName(propType);
95
+ }
96
+
97
+ if (propName !== '' && !aliasOrder.includes(prop.name) && !aliases.jobs.includes(propName)) {
98
+ aliases.jobs.push(propName);
99
+ }
100
+ }
101
+ }
102
+
103
+ function generateSingleAlias(
104
+ aliases: AliasMap,
105
+ aliasName: string,
106
+ aliasCode: AliasCodeMap,
107
+ options: CppCodegenOptions,
108
+ aliasOrder: string[],
109
+ ): void {
110
+ const aliasCppName = getAliasCppName(aliasName);
111
+ const aliasType = <NativeModuleObjectTypeAnnotation>aliases.types[aliasName];
112
+
113
+ checkTypes(aliases, aliasType, aliasOrder);
114
+
115
+ const definition = `
116
+ struct ${aliasCppName} {
117
+ ${translateObjectMembersDefinition(
118
+ aliasType,
119
+ aliases,
120
+ aliasName,
121
+ ' ',
122
+ options,
123
+ )}
124
+ };
125
+ `;
126
+ const reflection = `
127
+ inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(${aliasCppName}*) noexcept {
128
+ winrt::Microsoft::ReactNative::FieldMap fieldMap {
129
+ ${translateObjectMembersReflection(aliasType, aliasCppName, ' ')}
130
+ };
131
+ return fieldMap;
132
+ }
133
+ `;
134
+ aliasCode[aliasName] = {definition, reflection};
135
+ }
136
+
137
+ function generateNestedAliasesInCorrectOrder(
138
+ aliases: AliasMap,
139
+ aliasCode: AliasCodeMap,
140
+ aliasOrder: string[],
141
+ options: CppCodegenOptions,
142
+ ): void {
143
+ // retrieve and clean all ungenerated aliases
144
+ const jobs = aliases.jobs;
145
+ aliases.jobs = [];
146
+
147
+ // generate each one in its found order
148
+ for (const aliasName of jobs) {
149
+ // generate a new struct and all fields will be examined
150
+ // new anonymous objects could be found
151
+ // they will be stored in aliases.jobs
152
+ generateSingleAlias(aliases, aliasName, aliasCode, options, aliasOrder);
153
+ // nested C++ structs must be put before the current C++ struct
154
+ // as they will be used in the current C++ struct
155
+ // the order will be perfectly and easily ensured by doing this recursively
156
+ generateNestedAliasesInCorrectOrder(
157
+ aliases,
158
+ aliasCode,
159
+ aliasOrder,
160
+ options,
161
+ );
162
+ // all referenced C++ structs are generated
163
+ // put the current one following them
164
+ if (!aliasOrder.includes(aliasName)) {
165
+ aliasOrder.push(aliasName);
166
+ }
167
+ }
168
+ }
169
+
170
+ export function generateAliases(
171
+ aliases: AliasMap,
172
+ options: CppCodegenOptions,
173
+ ): [string, string] {
174
+ const aliasCode: AliasCodeMap = {};
175
+ const aliasOrder: string[] = [];
176
+ generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder, options);
177
+
178
+ // aliasOrder now has the correct order of C++ struct code
179
+ let customTypes = '';
180
+ let customReflection = '';
181
+ for (const aliasName of aliasOrder) {
182
+ customTypes = `${customTypes}${aliasCode[aliasName].definition}`;
183
+ customReflection = `${customReflection}${aliasCode[aliasName].reflection}`;
184
+ }
185
+ return [customTypes, customReflection];
186
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ import type {NativeModuleObjectTypeAnnotation} from '@react-native/codegen/lib/CodegenSchema';
10
+
11
+ let preferredModuleName: string = '';
12
+
13
+ export function setPreferredModuleName(moduleName: string): void {
14
+ preferredModuleName = moduleName;
15
+ }
16
+
17
+ export function getAliasCppName(typeName: string): string {
18
+ return `${preferredModuleName}Spec_${typeName}`;
19
+ }
20
+
21
+ export interface AliasMap<T = NativeModuleObjectTypeAnnotation> {
22
+ types: {[name: string]: T | undefined};
23
+ jobs: string[];
24
+ }
25
+
26
+ const ExtendedObjectKey = '$RNW-TURBOMODULE-ALIAS';
27
+ type ExtendedObject<T> = {
28
+ '$RNW-TURBOMODULE-ALIAS'?: string;
29
+ } & T;
30
+
31
+ function recordAnonymousAlias<T = NativeModuleObjectTypeAnnotation>(
32
+ aliases: AliasMap<T>,
33
+ baseAliasName: string,
34
+ extended: ExtendedObject<T>,
35
+ ): string {
36
+ extended[ExtendedObjectKey] = baseAliasName;
37
+ aliases.types[baseAliasName] = extended;
38
+ aliases.jobs.push(baseAliasName);
39
+ return baseAliasName;
40
+ }
41
+
42
+ export function getAnonymousAliasCppName<T = NativeModuleObjectTypeAnnotation>(
43
+ aliases: AliasMap<T>,
44
+ baseAliasName: string,
45
+ objectType: T,
46
+ ): string {
47
+ // someone found an anonymous object literal type
48
+ // if the ExtendedObjectKey flag has been set
49
+ // then it is a known one
50
+ // this happens because method signatures are generate twice in spec and error messages
51
+ const extended = <ExtendedObject<T>>objectType;
52
+ const key = extended[ExtendedObjectKey];
53
+ if (key !== undefined) {
54
+ return getAliasCppName(key);
55
+ }
56
+
57
+ // if the ExtendedObjectKey flag has not been set
58
+ // it means it is a unknown one
59
+ // associate the name with this object literal type and return
60
+ if (aliases.types[baseAliasName] === undefined) {
61
+ return getAliasCppName(
62
+ recordAnonymousAlias<T>(aliases, baseAliasName, extended),
63
+ );
64
+ }
65
+
66
+ // sometimes names could be anonymous
67
+ let index = 2;
68
+ while (aliases.types[`${baseAliasName}${index}`] !== undefined) {
69
+ index++;
70
+ }
71
+
72
+ return getAliasCppName(
73
+ recordAnonymousAlias(aliases, `${baseAliasName}${index}`, extended),
74
+ );
75
+ }