tests/cases/conformance/types/mapped/mappedTypeErrors.ts(20,20): error TS2313: Type parameter 'P' has a circular constraint.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(21,20): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(22,20): error TS2322: Type 'Date' is not assignable to type 'string'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(23,19): error TS2344: Type 'Date' does not satisfy the constraint 'string'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(26,24): error TS2344: Type '"foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(27,24): error TS2344: Type '"name" | "foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
  Type '"foo"' is not assignable to type '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(29,24): error TS2344: Type '"x" | "y"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
  Type '"x"' is not assignable to type '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(31,24): error TS2344: Type 'undefined' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(34,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
  Type 'T' is not assignable to type '"visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(38,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
  Type 'string | number' is not assignable to type '"name" | "width" | "height" | "visible"'.
    Type 'string' is not assignable to type '"name" | "width" | "height" | "visible"'.
      Type 'T' is not assignable to type '"visible"'.
        Type 'string | number' is not assignable to type '"visible"'.
          Type 'string' is not assignable to type '"visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(60,9): error TS2403: Subsequent variable declarations must have the same type.  Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]?: T[P] | undefined; }'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(61,9): error TS2403: Subsequent variable declarations must have the same type.  Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]: T[P]; }'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(62,9): error TS2403: Subsequent variable declarations must have the same type.  Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]?: T[P] | undefined; }'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(67,9): error TS2403: Subsequent variable declarations must have the same type.  Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]: T[P][]; }'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(76,45): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'Readonly<{ x: number; y: number; }>'.
  Property 'y' is missing in type '{ x: number; }'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(78,59): error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Readonly<{ x: number; y: number; }>'.
  Object literal may only specify known properties, and 'z' does not exist in type 'Readonly<{ x: number; y: number; }>'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(84,58): error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Partial<{ x: number; y: number; }>'.
  Object literal may only specify known properties, and 'z' does not exist in type 'Partial<{ x: number; y: number; }>'.


==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (17 errors) ====
    
    interface Shape {
        name: string;
        width: number;
        height: number;
        visible: boolean;
    }
    
    interface Named {
        name: string;
    }
    
    interface Point {
        x: number;
        y: number;
    }
    
    // Constraint checking
    
    type T00 = { [P in P]: string };  // Error
                       ~
!!! error TS2313: Type parameter 'P' has a circular constraint.
    type T01 = { [P in number]: string };  // Error
                       ~~~~~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
    type T02 = { [P in Date]: number };  // Error
                       ~~~~
!!! error TS2322: Type 'Date' is not assignable to type 'string'.
    type T03 = Record<Date, number>;  // Error
                      ~~~~
!!! error TS2344: Type 'Date' does not satisfy the constraint 'string'.
    
    type T10 = Pick<Shape, "name">;
    type T11 = Pick<Shape, "foo">;  // Error
                           ~~~~~
!!! error TS2344: Type '"foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
    type T12 = Pick<Shape, "name" | "foo">;  // Error
                           ~~~~~~~~~~~~~~
!!! error TS2344: Type '"name" | "foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
!!! error TS2344:   Type '"foo"' is not assignable to type '"name" | "width" | "height" | "visible"'.
    type T13 = Pick<Shape, keyof Named>;
    type T14 = Pick<Shape, keyof Point>;  // Error
                           ~~~~~~~~~~~
!!! error TS2344: Type '"x" | "y"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
!!! error TS2344:   Type '"x"' is not assignable to type '"name" | "width" | "height" | "visible"'.
    type T15 = Pick<Shape, never>;
    type T16 = Pick<Shape, undefined>;  // Error
                           ~~~~~~~~~
!!! error TS2344: Type 'undefined' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
    
    function f1<T>(x: T) {
        let y: Pick<Shape, T>;  // Error
                           ~
!!! error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
!!! error TS2344:   Type 'T' is not assignable to type '"visible"'.
    }
    
    function f2<T extends string | number>(x: T) {
        let y: Pick<Shape, T>;  // Error
                           ~
!!! error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
!!! error TS2344:   Type 'string | number' is not assignable to type '"name" | "width" | "height" | "visible"'.
!!! error TS2344:     Type 'string' is not assignable to type '"name" | "width" | "height" | "visible"'.
!!! error TS2344:       Type 'T' is not assignable to type '"visible"'.
!!! error TS2344:         Type 'string | number' is not assignable to type '"visible"'.
!!! error TS2344:           Type 'string' is not assignable to type '"visible"'.
    }
    
    function f3<T extends keyof Shape>(x: T) {
        let y: Pick<Shape, T>;
    }
    
    function f4<T extends keyof Named>(x: T) {
        let y: Pick<Shape, T>;
    }
    
    // Type identity checking
    
    function f10<T>() {
        type K = keyof T;
        var x: { [P in keyof T]: T[P] };
        var x: { [Q in keyof T]: T[Q] };
        var x: { [R in K]: T[R] };
    }
    
    function f11<T>() {
        var x: { [P in keyof T]: T[P] };
        var x: { [P in keyof T]?: T[P] };  // Error
            ~
!!! error TS2403: Subsequent variable declarations must have the same type.  Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]?: T[P] | undefined; }'.
        var x: { readonly [P in keyof T]: T[P] };  // Error
            ~
!!! error TS2403: Subsequent variable declarations must have the same type.  Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]: T[P]; }'.
        var x: { readonly [P in keyof T]?: T[P] };  // Error
            ~
!!! error TS2403: Subsequent variable declarations must have the same type.  Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]?: T[P] | undefined; }'.
    }
    
    function f12<T>() {
        var x: { [P in keyof T]: T[P] };
        var x: { [P in keyof T]: T[P][] };  // Error
            ~
!!! error TS2403: Subsequent variable declarations must have the same type.  Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]: T[P][]; }'.
    }
    
    // Check that inferences to mapped types are secondary
    
    declare function objAndReadonly<T>(primary: T, secondary: Readonly<T>): T;
    declare function objAndPartial<T>(primary: T, secondary: Partial<T>): T;
    
    function f20() {
        let x1 = objAndReadonly({ x: 0, y: 0 }, { x: 1 });  // Error
                                                ~~~~~~~~
!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'Readonly<{ x: number; y: number; }>'.
!!! error TS2345:   Property 'y' is missing in type '{ x: number; }'.
        let x2 = objAndReadonly({ x: 0, y: 0 }, { x: 1, y: 1 });
        let x3 = objAndReadonly({ x: 0, y: 0 }, { x: 1, y: 1, z: 1 });  // Error
                                                              ~~~~
!!! error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Readonly<{ x: number; y: number; }>'.
!!! error TS2345:   Object literal may only specify known properties, and 'z' does not exist in type 'Readonly<{ x: number; y: number; }>'.
    }
    
    function f21() {
        let x1 = objAndPartial({ x: 0, y: 0 }, { x: 1 });
        let x2 = objAndPartial({ x: 0, y: 0 }, { x: 1, y: 1 });
        let x3 = objAndPartial({ x: 0, y: 0 }, { x: 1, y: 1, z: 1 });  // Error
                                                             ~~~~
!!! error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Partial<{ x: number; y: number; }>'.
!!! error TS2345:   Object literal may only specify known properties, and 'z' does not exist in type 'Partial<{ x: number; y: number; }>'.
    }