TS9001: No Instance Found
Category: Typeclass Resolution
Severity: Error
Message
No instance of '{typeclass}' found for type '{type}'Explanation
The typesugar compiler couldn't find a typeclass instance to use at a call site. This happens when you:
- Call
summon<TC<T>>()for a typeclassTCand typeTthat doesn't have an instance - Use an operator like
===or method like.show()on a type without the required typeclass instance - Have nested types where an inner field type lacks the required instance
Common Causes
1. Missing @derive annotation
typescript
// Error: No instance of 'Eq' found for type 'Point'
interface Point {
x: number;
y: number;
}
const p1: Point = { x: 1, y: 2 };
const p2: Point = { x: 1, y: 2 };
console.log(p1 === p2); // TS9001Fix: Add @derive(Eq) to the type:
typescript
@derive(Eq)
interface Point {
x: number;
y: number;
}2. Field type lacks instance
typescript
@derive(Eq)
interface Container {
data: CustomType; // CustomType doesn't have Eq
}Fix: Either derive Eq for CustomType, or provide a custom instance:
typescript
@derive(Eq)
class CustomType { /* ... */ }
// Or define a custom @instance (attaches to CustomType companion)
@instance
const eqCustomType: Eq<CustomType> = {
equals: (a, b) => /* custom logic */
};
// Access via: CustomType.Eq3. Generic type without constraint
typescript
function compare<T>(a: T, b: T): boolean {
return summon<Eq<T>>().equals(a, b); // TS9001 if T has no Eq constraint
}Fix: Add a typeclass constraint with = implicit():
typescript
// Option 1: Explicit parameter (caller must pass it)
function compare<T>(a: T, b: T, eq: Eq<T>): boolean {
return eq.equals(a, b);
}
// Option 2: Use = implicit() to auto-fill (caller can still override)
function compare<T>(a: T, b: T, eq: Eq<T> = implicit()): boolean {
return eq.equals(a, b);
}Suppression
If you intentionally want to skip typeclass resolution for specific code, you can use the explicit form:
typescript
// Instead of relying on implicit resolution
p1 === p2;
// Use explicit equality check if you know it's safe
JSON.stringify(p1) === JSON.stringify(p2);See Also
- Typeclass Guide
- Derive Guide
- TS9102 - Missing field instance
