Closed
Description
type Disarray<Type> = Type extends ReadonlyArray<infer Element> ? Element : Type;
interface L {
facilities: string[];
coords: number[];
}
declare var d: {
// broken
$pull?: { a?: 1 } & { [key in keyof L]?: { eq?: "unassignable" } } // used to have Disarray<TSchema[key]>, to get the correct error
// OK
$push?: { [key in keyof L]?: Disarray<L[key]>;}
} & {
b?: 2
};
d = { $pull: { coords: "should be type error" } }
d = { $pull: { facilities: -1 } }
d = { $push: { coords: "should be type error" } }
d = { $push: { facilities: -1 } }
Expected: Errors on all
Actual: Only errors on the $push assignments.
Broken by #43707
The break should apply to all users of mongodb, mongoose just has the most tests.