Skip to content

#43707 drops correct errors for @types/mongoose #43884

Closed
@sandersn

Description

@sandersn
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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions