MCPcopy Index your code
hub / github.com/glideapps/quicktype / emitSourceStructure

Method emitSourceStructure

src/Language/TypeScript.ts:366–398  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

364 };
365
366 protected emitSourceStructure() {
367 if (!this._justTypes) {
368 this.emitMultiline(`// To parse this data:
369//`);
370 const topLevelNames: Sourcelike[] = [];
371 this.forEachTopLevel(
372 "none",
373 (_t, name) => {
374 topLevelNames.push(", ", name);
375 },
376 t => t.isNamedType()
377 );
378
379 this.emitLine("// import { Convert", topLevelNames, ' } from "./file";');
380 this.emitLine("//");
381 this.forEachTopLevel("none", (_t, name) => {
382 const camelCaseName = modifySource(camelCase, name);
383 this.emitLine("// const ", camelCaseName, " = Convert.to", name, "(json);");
384 });
385 if (this._runtimeTypecheck) {
386 this.emitLine("//");
387 this.emitLine("// These functions will throw an error if the JSON doesn't");
388 this.emitLine("// match the expected interface, even if the JSON is valid.");
389 }
390 this.emitNewline();
391 }
392
393 this.forEachNamedType("none", false, this.emitClass, this.emitEnum, this.emitUnion);
394
395 if (!this._justTypes) {
396 this.emitConvertModule();
397 }
398 }
399}

Callers

nothing calls this directly

Calls 1

modifySourceFunction · 0.90

Tested by

no test coverage detected