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

Function checkTypeof

ark/aot/graph.ts:6835–6850  ·  view source on GitHub ↗
(a: Node, b: Node)

Source from the content-addressed store, hash-verified

6833 const isEq = test.operator === "===" || test.operator === "=="
6834 const holdsEq = expectTruthy ? isEq : !isEq
6835 const checkTypeof = (a: Node, b: Node): boolean => {
6836 const ua = unwrapExpression(a)
6837 const ub = unwrapExpression(b)
6838 if (
6839 ua.type === "UnaryExpression" &&
6840 ua.operator === "typeof" &&
6841 isBoundId(ua.argument, binding, module) &&
6842 ub.type === "Literal" &&
6843 typeof ub.value === "string"
6844 ) {
6845 return holdsEq ?
6846 ub.value in nonFunctionTypeofs
6847 : ub.value === "function"
6848 }
6849 return false
6850 }
6851 if (
6852 checkTypeof(test.left, test.right) ||
6853 checkTypeof(test.right, test.left)

Callers 1

testProvesNotFunctionFunction · 0.85

Calls 2

unwrapExpressionFunction · 0.90
isBoundIdFunction · 0.85

Tested by

no test coverage detected