()
| 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 | } |
nothing calls this directly
no test coverage detected