MCPcopy Create free account
hub / github.com/breck7/scroll / toTypeScriptInterface

Method toTypeScriptInterface

external/.scrollLibs.js:19451–19477  ·  view source on GitHub ↗
(used = new Set())

Source from the content-addressed store, hash-verified

19449 return new Particle.ParserPool(undefined, map, [{ regex: HandParsersProgram.parserFullRegex, parser: parserDefinitionParser }])
19450 }
19451 toTypeScriptInterface(used = new Set()) {
19452 let subparticlesInterfaces = []
19453 let properties = []
19454 const inScope = this.cueMapWithDefinitions
19455 const thisId = this.id
19456 used.add(thisId)
19457 Object.keys(inScope).forEach(key => {
19458 const def = inScope[key]
19459 const map = def.cueMapWithDefinitions
19460 const id = def.id
19461 const optionalTag = def.isRequired() ? "" : "?"
19462 const escapedKey = key.match(/\?/) ? `"${key}"` : key
19463 const description = def.description
19464 if (Object.keys(map).length && !used.has(id)) {
19465 subparticlesInterfaces.push(def.toTypeScriptInterface(used))
19466 properties.push(` ${escapedKey}${optionalTag}: ${id}`)
19467 } else properties.push(` ${escapedKey}${optionalTag}: any${description ? " // " + description : ""}`)
19468 })
19469 properties.sort()
19470 const description = this.description
19471 const myInterface = ""
19472 return `${subparticlesInterfaces.join("\n")}
19473${description ? "// " + description : ""}
19474interface ${thisId} {
19475${properties.join("\n")}
19476}`.trim()
19477 }
19478 get id() {
19479 return this.getAtom(0)
19480 }

Callers

nothing calls this directly

Calls 7

forEachMethod · 0.80
isRequiredMethod · 0.80
sortMethod · 0.80
trimMethod · 0.80
addMethod · 0.45
hasMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected