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

Function computeSkippedFunction

ark/aot/usage.ts:1806–1837  ·  view source on GitHub ↗
(
	fn: Node,
	module: SourceModule,
	ctx: ThisReadsContext
)

Source from the content-addressed store, hash-verified

1804}
1805
1806const computeSkippedFunction = (
1807 fn: Node,
1808 module: SourceModule,
1809 ctx: ThisReadsContext
1810): boolean => {
1811 const classMember = classMemberParentOf(fn)
1812 if (classMember) {
1813 // class-field function expressions are own enumerable properties and can be
1814 // detached by spread, Object.assign, or property reads — always index them
1815 if (classMember.type !== "MethodDefinition") return false
1816 // ES6 class constructors throw without `new` and cannot bind an object literal
1817 if (classMember.kind === "constructor") return true
1818 const key = classMemberKeyOf(classMember, module)
1819 if (key === undefined) return false
1820 if (ctx.hasProtoInheritance || ctx.hasDescriptorRead) return false
1821 if (classMember.kind === "method" && ctx.uncalledKeys.has(key)) return false
1822 const cls = classMember.parent?.parent
1823 if (
1824 !cls ||
1825 (cls.type !== "ClassDeclaration" && cls.type !== "ClassExpression")
1826 )
1827 return false
1828 return !classExposesMembers(cls, module, ctx)
1829 }
1830 const es5Method = es5ProtoMethodOf(fn, module)
1831 if (es5Method) {
1832 if (ctx.hasProtoInheritance || ctx.hasDescriptorRead) return false
1833 if (ctx.uncalledKeys.has(es5Method.methodKey)) return false
1834 return !ctorExposesPrototype(es5Method.ctorBinding, module, ctx)
1835 }
1836 return isDeadTopLevelFunction(fn, module, ctx)
1837}
1838
1839const instanceExposesComputed = (
1840 newExpr: Node,

Callers 1

isSkippedFunctionFunction · 0.85

Calls 7

classMemberParentOfFunction · 0.85
classMemberKeyOfFunction · 0.85
classExposesMembersFunction · 0.85
es5ProtoMethodOfFunction · 0.85
ctorExposesPrototypeFunction · 0.85
isDeadTopLevelFunctionFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected