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

Method calledKindOf

ark/aot/graph.ts:3874–3938  ·  view source on GitHub ↗
(
		node: CallExpression | TaggedTemplateExpression,
		module: SourceModule,
		kindOfKey: KindOfKey
	)

Source from the content-addressed store, hash-verified

3872 // what a call returns: a Type from arktype's parsers or a Scope's, a
3873 // Generic from a definition with parameters, or what its callee returns
3874 private calledKindOf(
3875 node: CallExpression | TaggedTemplateExpression,
3876 module: SourceModule,
3877 kindOfKey: KindOfKey
3878 ): KindBits {
3879 const callee = unwrapChain(
3880 node.type === "CallExpression" ? node.callee : node.tag
3881 )
3882 // e.g. `type({ a: "string" })`, as only parameters make a Generic
3883 if (
3884 node.type === "CallExpression" &&
3885 definesType(node) &&
3886 this.arkExportNameOf(callee, module) === "type"
3887 )
3888 return kinds.type
3889 if (
3890 callee.type === "MemberExpression" &&
3891 (memberNameOf(callee) as never) in typeParserTypes &&
3892 this.arkExportNameOf(callee.object, module) === "type"
3893 )
3894 return kinds.type
3895 // e.g. `$.type("User")`, with `$` a Scope, or `type.declare<User>().type(def)`
3896 if (
3897 node.type === "CallExpression" &&
3898 definesType(node) &&
3899 callee.type === "MemberExpression" &&
3900 memberNameOf(callee) === "type" &&
3901 (this.scopeCallOf(callee.object, module, kindOfKey) ||
3902 this.isDeclaration(callee.object, module, kindOfKey))
3903 )
3904 return kinds.type
3905 if (
3906 node.type === "CallExpression" &&
3907 this.definesGeneric(node, module, kindOfKey)
3908 )
3909 return genericKind
3910 const fn =
3911 this.functionOf(callee, module) ??
3912 this.methodOf(callee, module, kindOfKey)
3913 if (!fn) {
3914 const unrefed = node.type === "CallExpression" && unrefedOf(node, module)
3915 if (unrefed) return this.transfer(unrefed, module, kindOfKey)
3916 if (node.type === "CallExpression") {
3917 const global = this.globalMemberOf(callee, module)
3918 if (
3919 global &&
3920 global in identityObjectMethods &&
3921 node.arguments[0] &&
3922 node.arguments[0].type !== "SpreadElement"
3923 )
3924 return this.transfer(node.arguments[0], module, kindOfKey)
3925 if (global && global in predicateObjectMethods) return kinds.data
3926 }
3927 return (
3928 callKindOf(this.transfer(callee, module, kindOfKey)) |
3929 (node.type === "CallExpression" ?
3930 this.builtinPassedOf(node, module, kindOfKey)
3931 : 0)

Callers 1

transferMethod · 0.95

Calls 15

arkExportNameOfMethod · 0.95
scopeCallOfMethod · 0.95
isDeclarationMethod · 0.95
definesGenericMethod · 0.95
functionOfMethod · 0.95
methodOfMethod · 0.95
transferMethod · 0.95
globalMemberOfMethod · 0.95
builtinPassedOfMethod · 0.95
applicationOfMethod · 0.95
unwrapChainFunction · 0.90
runtimeParamsOfFunction · 0.90

Tested by

no test coverage detected