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

Function getStringifiableType

ark/attest/cache/ts.ts:288–311  ·  view source on GitHub ↗
(node: ts.Node)

Source from the content-addressed store, hash-verified

286}
287
288export const getStringifiableType = (node: ts.Node): StringifiableType => {
289 const typeChecker = getInternalTypeChecker()
290 const nodeType = typeChecker.getTypeAtLocation(node)
291
292 let stringified = typeChecker.typeToString(nodeType)
293
294 if (stringified.includes("...")) {
295 const nonTruncated = typeChecker.typeToString(
296 nodeType,
297 undefined,
298 ts.TypeFormatFlags.NoTruncation
299 )
300
301 stringified =
302 nonTruncated.includes(" any") && !stringified.includes(" any") ?
303 nonTruncated.replace(/ any/g, " cyclic")
304 : nonTruncated
305 }
306
307 return Object.assign(nodeType, {
308 toString: () => stringified,
309 isUnresolvable: (nodeType as any).intrinsicName === "error"
310 })
311}
312
313export type ArgumentTypes = {
314 args: StringifiableType[]

Callers 2

describeTypeFunction · 0.90

Calls 2

getInternalTypeCheckerFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected