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

Function constructsReflectively

ark/aot/graph.ts:7450–7468  ·  view source on GitHub ↗
(module: SourceModule)

Source from the content-addressed store, hash-verified

7448
7449// e.g. `new this(A)` or `new t.constructor(A)`
7450const constructsReflectively = (module: SourceModule): boolean => {
7451 let result = constructsByModule.get(module)
7452 if (result === undefined) {
7453 result = false
7454 walk(module.program, node => {
7455 if (
7456 (node.type === "NewExpression" &&
7457 unwrapExpression(node.callee).type === "ThisExpression") ||
7458 (node.type === "MetaProperty" && node.meta.name === "new") ||
7459 (node.type === "MemberExpression" &&
7460 memberNameOf(node) === "constructor")
7461 )
7462 result = true
7463 return !result
7464 })
7465 constructsByModule.set(module, result)
7466 }
7467 return result
7468}
7469
7470const importsValuesByModule = new WeakMap<SourceModule, boolean>()
7471

Callers 1

callsOfMethod · 0.85

Calls 5

walkFunction · 0.90
unwrapExpressionFunction · 0.90
memberNameOfFunction · 0.70
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected