Skip to content

Commit

Permalink
Accept new baselines
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg committed Nov 15, 2016
1 parent 04a0f55 commit 997c586
Show file tree
Hide file tree
Showing 5 changed files with 342 additions and 297 deletions.
71 changes: 45 additions & 26 deletions tests/baselines/reference/mappedTypeErrors.errors.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(34,20): error TS2313: Type parameter 'P' has a circular constraint.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(35,20): error TS2322: Type 'Date' is not assignable to type 'string | number'.
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 'Date' is not assignable to type 'string | number'.
Type 'Date' is not assignable to type 'number'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(36,19): error TS2344: Type 'Date' does not satisfy the constraint 'string | number'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(22,19): error TS2344: Type 'Date' does not satisfy the constraint 'string | number'.
Type 'Date' is not assignable to type 'number'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(39,24): error TS2344: Type '"foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(40,24): error TS2344: Type '"name" | "foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(25,24): error TS2344: Type '"foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(26,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(42,24): error TS2344: Type '"x" | "y"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(28,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(44,24): error TS2344: Type 'undefined' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(47,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(30,24): error TS2344: Type 'undefined' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(33,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(51,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(37,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(59,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(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 '{ readonly [P in keyof T]: T[P]; }'.
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(66,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 (9 errors) ====

type Partial<T> = {
[P in keyof T]?: T[P];
};

type Readonly<T> = {
readonly [P in keyof T]: T[P];
};

type Pick<T, K extends keyof T> = {
[P in K]: T[P];
}

type Record<K extends string | number, T> = {
[_ in K]: T;
}
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (13 errors) ====

interface Shape {
name: string;
Expand All @@ -53,6 +41,8 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(51,24): error TS2344: T
y: number;
}

// Constraint checking

type T00 = { [P in P]: string }; // Error
~
!!! error TS2313: Type parameter 'P' has a circular constraint.
Expand Down Expand Up @@ -107,4 +97,33 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(51,24): error TS2344: 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]; }'.
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]; }'.
}

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][]; }'.
}
70 changes: 42 additions & 28 deletions tests/baselines/reference/mappedTypeErrors.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
//// [mappedTypeErrors.ts]

type Partial<T> = {
[P in keyof T]?: T[P];
};

type Readonly<T> = {
readonly [P in keyof T]: T[P];
};

type Pick<T, K extends keyof T> = {
[P in K]: T[P];
}

type Record<K extends string | number, T> = {
[_ in K]: T;
}

interface Shape {
name: string;
width: number;
Expand All @@ -32,6 +16,8 @@ interface Point {
y: number;
}

// Constraint checking

type T00 = { [P in P]: string }; // Error
type T01 = { [P in Date]: number }; // Error
type T02 = Record<Date, number>; // Error
Expand All @@ -58,6 +44,27 @@ function f3<T extends keyof Shape>(x: 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
var x: { readonly [P in keyof T]: T[P] }; // Error
var x: { readonly [P in keyof T]?: T[P] }; // Error
}

function f12<T>() {
var x: { [P in keyof T]: T[P] };
var x: { [P in keyof T]: T[P][] }; // Error
}

//// [mappedTypeErrors.js]
Expand All @@ -73,21 +80,25 @@ function f3(x) {
function f4(x) {
var y;
}
// Type identity checking
function f10() {
var x;
var x;
var x;
}
function f11() {
var x;
var x; // Error
var x; // Error
var x; // Error
}
function f12() {
var x;
var x; // Error
}


//// [mappedTypeErrors.d.ts]
declare type Partial<T> = {
[P in keyof T]?: T[P];
};
declare type Readonly<T> = {
readonly [P in keyof T]: T[P];
};
declare type Pick<T, K extends keyof T> = {
[P in K]: T[P];
};
declare type Record<K extends string | number, T> = {
[_ in K]: T;
};
interface Shape {
name: string;
width: number;
Expand Down Expand Up @@ -119,3 +130,6 @@ declare function f1<T>(x: T): void;
declare function f2<T extends string | number>(x: T): void;
declare function f3<T extends keyof Shape>(x: T): void;
declare function f4<T extends keyof Named>(x: T): void;
declare function f10<T>(): void;
declare function f11<T>(): void;
declare function f12<T>(): void;
46 changes: 20 additions & 26 deletions tests/baselines/reference/mappedTypes2.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
//// [mappedTypes2.ts]

type Partial<T> = {
[P in keyof T]?: T[P];
};

type Readonly<T> = {
readonly [P in keyof T]: T[P];
};

type Pick<T, K extends keyof T> = {
[P in K]: T[P];
}

type Record<K extends string | number, T> = {
[_ in K]: T;
function verifyLibTypes<T, K extends keyof T, U>() {
var x1: Partial<T>;
var x1: { [P in keyof T]?: T[P] };
var x2: Readonly<T>;
var x2: { readonly [P in keyof T]: T[P] };
var x3: Pick<T, K>;
var x3: { [P in K]: T[P] };
var x4: Record<K, U>;
var x4: { [P in K]: U };
}

type Proxy<T> = {
Expand Down Expand Up @@ -95,6 +90,16 @@ function f6(shape: DeepReadonly<Shape>) {
}

//// [mappedTypes2.js]
function verifyLibTypes() {
var x1;
var x1;
var x2;
var x2;
var x3;
var x3;
var x4;
var x4;
}
function f0(s1, s2) {
assign(s1, { name: "circle" });
assign(s2, { width: 10, height: 20 });
Expand Down Expand Up @@ -129,18 +134,7 @@ function f6(shape) {


//// [mappedTypes2.d.ts]
declare type Partial<T> = {
[P in keyof T]?: T[P];
};
declare type Readonly<T> = {
readonly [P in keyof T]: T[P];
};
declare type Pick<T, K extends keyof T> = {
[P in K]: T[P];
};
declare type Record<K extends string | number, T> = {
[_ in K]: T;
};
declare function verifyLibTypes<T, K extends keyof T, U>(): void;
declare type Proxy<T> = {
get(): T;
set(value: T): void;
Expand Down
Loading

0 comments on commit 997c586

Please sign in to comment.