MCPcopy Create free account
hub / github.com/Snapchat/Valdi / generateTypeScriptIds

Function generateTypeScriptIds

compiler/companion/src/GenerateIds.ts:157–192  ·  view source on GitHub ↗
(ids: Id[])

Source from the content-addressed store, hash-verified

155}
156
157function generateTypeScriptIds(ids: Id[]): TypeScriptFile {
158 const definition = new OutputWriter();
159 const implementation = new OutputWriter();
160
161 definition.append('export class Ids {\n');
162 implementation.append('module.exports.Ids = {\n');
163
164 definition.beginIndent(' ');
165 implementation.beginIndent(' ');
166
167 let first = true;
168 for (const id of ids) {
169 if (!first) {
170 definition.append('\n');
171 }
172 first = false;
173
174 if (id.description) {
175 definition.append(GeneratedFileHeader.generateMultilineComment(id.description));
176 }
177 definition.append(`static ${id.name}(): string;\n`);
178
179 implementation.append(`${id.name}: () => '${escapeJSSingleQuotedString(id.identifier)}',\n`);
180 }
181
182 definition.endIndent();
183 implementation.endIndent();
184
185 implementation.append('}\n');
186 definition.append('}\n');
187
188 return {
189 definition: definition.content(),
190 implementation: implementation.content(),
191 };
192}
193
194export function generateIds(moduleName: string, iosHeaderImportPath: string, fileContent: string): GenerateIds {
195 const ids = parseIds(moduleName, fileContent);

Callers 1

generateIdsFunction · 0.85

Calls 6

appendMethod · 0.95
beginIndentMethod · 0.95
endIndentMethod · 0.95
contentMethod · 0.95

Tested by

no test coverage detected