( l: StringifiableType, r: StringifiableType )
| 272 | .join("\n") |
| 273 | |
| 274 | export const compareTsTypes = ( |
| 275 | l: StringifiableType, |
| 276 | r: StringifiableType |
| 277 | ): TypeRelationship => { |
| 278 | const lString = l.toString() |
| 279 | const rString = r.toString() |
| 280 | // Ensure two unresolvable types are not treated as equivalent |
| 281 | if (l.isUnresolvable || r.isUnresolvable) return "none" |
| 282 | // Treat `any` as a supertype of every other type |
| 283 | if (lString === "any") return rString === "any" ? "equality" : "supertype" |
| 284 | if (rString === "any") return "subtype" |
| 285 | // Otherwise, determine if the types are equivalent by checking mutual assignability |
| 286 | const checker = getInternalTypeChecker() |
| 287 | const isSubtype = checker.isTypeAssignableTo(l, r) |
| 288 | const isSupertype = checker.isTypeAssignableTo(r, l) |
| 289 | return ( |
| 290 | isSubtype ? |
| 291 | isSupertype ? "equality" |
| 292 | : "subtype" |
| 293 | : isSupertype ? "supertype" |
| 294 | : "none" |
| 295 | ) |
| 296 | } |
| 297 | |
| 298 | export const checkDiagnosticMessages = ( |
| 299 | attestCall: ts.CallExpression, |
no test coverage detected