(node: ts.Node)
| 286 | } |
| 287 | |
| 288 | export 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 | |
| 313 | export type ArgumentTypes = { |
| 314 | args: StringifiableType[] |
no test coverage detected