( l: StringifiableType, r: StringifiableType )
| 308 | export type TypeRelationship = "subtype" | "supertype" | "equality" | "none" |
| 309 | |
| 310 | export const compareTsTypes = ( |
| 311 | l: StringifiableType, |
| 312 | r: StringifiableType |
| 313 | ): TypeRelationship => { |
| 314 | const lString = l.toString() |
| 315 | const rString = r.toString() |
| 316 | // Ensure two unresolvable types are not treated as equivalent |
| 317 | if (l.isUnresolvable || r.isUnresolvable) return "none" |
| 318 | // Treat `any` as a supertype of every other type |
| 319 | if (lString === "any") return rString === "any" ? "equality" : "supertype" |
| 320 | if (rString === "any") return "subtype" |
| 321 | // Otherwise, determine if the types are equivalent by checking mutual assignability |
| 322 | const checker = getInternalTypeChecker() |
| 323 | const isSubtype = checker.isTypeAssignableTo(l, r) |
| 324 | const isSupertype = checker.isTypeAssignableTo(r, l) |
| 325 | return ( |
| 326 | isSubtype ? |
| 327 | isSupertype ? "equality" |
| 328 | : "subtype" |
| 329 | : isSupertype ? "supertype" |
| 330 | : "none" |
| 331 | ) |
| 332 | } |
| 333 | |
| 334 | export const checkDiagnosticMessages = ( |
| 335 | attestCall: ts.CallExpression, |
no test coverage detected
searching dependent graphs…