MCPcopy Create free account
hub / github.com/arktypeio/arktype / constructor

Method constructor

ark/aot/scope.ts:76–96  ·  view source on GitHub ↗
(program: Program)

Source from the content-addressed store, hash-verified

74 isCommonJs = false
75
76 constructor(program: Program) {
77 this.root = this.scope = createScope(program, undefined)
78 this.byNode.set(program, this.root)
79 for (const statement of program.body) this.visit(statement, program)
80 this.close()
81 for (const reference of this.references) {
82 if (reference.binding && reference.isWrite)
83 reference.binding.writes.push(reference.id)
84 }
85 if (
86 !program.body.some(statement => statement.type in moduleSyntaxKinds) &&
87 this.root.unresolved.some(({ id }) => id.name in commonJsGlobals)
88 ) {
89 this.isCommonJs = true
90 this.readCommonJs(program)
91 }
92 for (const name in this.exportsByName) {
93 const entry = this.exportsByName[name]
94 if (entry.kind === "binding") entry.binding.exportNames.push(name)
95 }
96 }
97
98 // what tsc writes for a module's exports where it emits CommonJS, read as
99 // the declarations they were: `exports.a = value`, `__exportStar(

Callers

nothing calls this directly

Calls 6

visitMethod · 0.95
closeMethod · 0.95
readCommonJsMethod · 0.95
createScopeFunction · 0.85
setMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected