Accept new baselines

This commit is contained in:
Anders Hejlsberg 2018-04-24 15:57:26 -07:00
parent 50c7ff79d0
commit b78054d9c3
4 changed files with 271 additions and 0 deletions

View File

@ -0,0 +1,71 @@
tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(7,9): error TS2322: Type 'T & U' is not assignable to type 'string | number'.
Type 'string | undefined' is not assignable to type 'string | number'.
Type 'undefined' is not assignable to type 'string | number'.
Type 'T & U' is not assignable to type 'number'.
tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(8,9): error TS2322: Type 'T & U' is not assignable to type 'string | null'.
Type 'string | undefined' is not assignable to type 'string | null'.
Type 'undefined' is not assignable to type 'string | null'.
Type 'T & U' is not assignable to type 'string'.
tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(10,9): error TS2322: Type 'T & U' is not assignable to type 'number | null'.
Type 'string | undefined' is not assignable to type 'number | null'.
Type 'undefined' is not assignable to type 'number | null'.
Type 'T & U' is not assignable to type 'number'.
tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(11,9): error TS2322: Type 'T & U' is not assignable to type 'number | undefined'.
Type 'string | undefined' is not assignable to type 'number | undefined'.
Type 'string' is not assignable to type 'number | undefined'.
Type 'T & U' is not assignable to type 'number'.
tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(12,9): error TS2322: Type 'T & U' is not assignable to type 'null | undefined'.
Type 'string | undefined' is not assignable to type 'null | undefined'.
Type 'string' is not assignable to type 'null | undefined'.
Type 'T & U' is not assignable to type 'null'.
==== tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts (5 errors) ====
function f1<T extends string | number, U extends string | number>(x: T & U) {
// Combined constraint of 'T & U' is 'string | number'
let y: string | number = x;
}
function f2<T extends string | number | undefined, U extends string | null | undefined>(x: T & U) {
let y1: string | number = x; // Error
~~
!!! error TS2322: Type 'T & U' is not assignable to type 'string | number'.
!!! error TS2322: Type 'string | undefined' is not assignable to type 'string | number'.
!!! error TS2322: Type 'undefined' is not assignable to type 'string | number'.
!!! error TS2322: Type 'T & U' is not assignable to type 'number'.
let y2: string | null = x; // Error
~~
!!! error TS2322: Type 'T & U' is not assignable to type 'string | null'.
!!! error TS2322: Type 'string | undefined' is not assignable to type 'string | null'.
!!! error TS2322: Type 'undefined' is not assignable to type 'string | null'.
!!! error TS2322: Type 'T & U' is not assignable to type 'string'.
let y3: string | undefined = x;
let y4: number | null = x; // Error
~~
!!! error TS2322: Type 'T & U' is not assignable to type 'number | null'.
!!! error TS2322: Type 'string | undefined' is not assignable to type 'number | null'.
!!! error TS2322: Type 'undefined' is not assignable to type 'number | null'.
!!! error TS2322: Type 'T & U' is not assignable to type 'number'.
let y5: number | undefined = x; // Error
~~
!!! error TS2322: Type 'T & U' is not assignable to type 'number | undefined'.
!!! error TS2322: Type 'string | undefined' is not assignable to type 'number | undefined'.
!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'.
!!! error TS2322: Type 'T & U' is not assignable to type 'number'.
let y6: null | undefined = x; // Error
~~
!!! error TS2322: Type 'T & U' is not assignable to type 'null | undefined'.
!!! error TS2322: Type 'string | undefined' is not assignable to type 'null | undefined'.
!!! error TS2322: Type 'string' is not assignable to type 'null | undefined'.
!!! error TS2322: Type 'T & U' is not assignable to type 'null'.
}
type T1 = (string | number | undefined) & (string | null | undefined); // string | undefined
// Repro from #23648
type Example<T, U> = { [K in keyof T]: K extends keyof U ? UnexpectedError<K> : NoErrorHere<K> }
type UnexpectedError<T extends PropertyKey> = T
type NoErrorHere<T extends PropertyKey> = T

View File

@ -0,0 +1,39 @@
//// [intersectionWithUnionConstraint.ts]
function f1<T extends string | number, U extends string | number>(x: T & U) {
// Combined constraint of 'T & U' is 'string | number'
let y: string | number = x;
}
function f2<T extends string | number | undefined, U extends string | null | undefined>(x: T & U) {
let y1: string | number = x; // Error
let y2: string | null = x; // Error
let y3: string | undefined = x;
let y4: number | null = x; // Error
let y5: number | undefined = x; // Error
let y6: null | undefined = x; // Error
}
type T1 = (string | number | undefined) & (string | null | undefined); // string | undefined
// Repro from #23648
type Example<T, U> = { [K in keyof T]: K extends keyof U ? UnexpectedError<K> : NoErrorHere<K> }
type UnexpectedError<T extends PropertyKey> = T
type NoErrorHere<T extends PropertyKey> = T
//// [intersectionWithUnionConstraint.js]
"use strict";
function f1(x) {
// Combined constraint of 'T & U' is 'string | number'
var y = x;
}
function f2(x) {
var y1 = x; // Error
var y2 = x; // Error
var y3 = x;
var y4 = x; // Error
var y5 = x; // Error
var y6 = x; // Error
}

View File

@ -0,0 +1,78 @@
=== tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts ===
function f1<T extends string | number, U extends string | number>(x: T & U) {
>f1 : Symbol(f1, Decl(intersectionWithUnionConstraint.ts, 0, 0))
>T : Symbol(T, Decl(intersectionWithUnionConstraint.ts, 0, 12))
>U : Symbol(U, Decl(intersectionWithUnionConstraint.ts, 0, 38))
>x : Symbol(x, Decl(intersectionWithUnionConstraint.ts, 0, 66))
>T : Symbol(T, Decl(intersectionWithUnionConstraint.ts, 0, 12))
>U : Symbol(U, Decl(intersectionWithUnionConstraint.ts, 0, 38))
// Combined constraint of 'T & U' is 'string | number'
let y: string | number = x;
>y : Symbol(y, Decl(intersectionWithUnionConstraint.ts, 2, 7))
>x : Symbol(x, Decl(intersectionWithUnionConstraint.ts, 0, 66))
}
function f2<T extends string | number | undefined, U extends string | null | undefined>(x: T & U) {
>f2 : Symbol(f2, Decl(intersectionWithUnionConstraint.ts, 3, 1))
>T : Symbol(T, Decl(intersectionWithUnionConstraint.ts, 5, 12))
>U : Symbol(U, Decl(intersectionWithUnionConstraint.ts, 5, 50))
>x : Symbol(x, Decl(intersectionWithUnionConstraint.ts, 5, 88))
>T : Symbol(T, Decl(intersectionWithUnionConstraint.ts, 5, 12))
>U : Symbol(U, Decl(intersectionWithUnionConstraint.ts, 5, 50))
let y1: string | number = x; // Error
>y1 : Symbol(y1, Decl(intersectionWithUnionConstraint.ts, 6, 7))
>x : Symbol(x, Decl(intersectionWithUnionConstraint.ts, 5, 88))
let y2: string | null = x; // Error
>y2 : Symbol(y2, Decl(intersectionWithUnionConstraint.ts, 7, 7))
>x : Symbol(x, Decl(intersectionWithUnionConstraint.ts, 5, 88))
let y3: string | undefined = x;
>y3 : Symbol(y3, Decl(intersectionWithUnionConstraint.ts, 8, 7))
>x : Symbol(x, Decl(intersectionWithUnionConstraint.ts, 5, 88))
let y4: number | null = x; // Error
>y4 : Symbol(y4, Decl(intersectionWithUnionConstraint.ts, 9, 7))
>x : Symbol(x, Decl(intersectionWithUnionConstraint.ts, 5, 88))
let y5: number | undefined = x; // Error
>y5 : Symbol(y5, Decl(intersectionWithUnionConstraint.ts, 10, 7))
>x : Symbol(x, Decl(intersectionWithUnionConstraint.ts, 5, 88))
let y6: null | undefined = x; // Error
>y6 : Symbol(y6, Decl(intersectionWithUnionConstraint.ts, 11, 7))
>x : Symbol(x, Decl(intersectionWithUnionConstraint.ts, 5, 88))
}
type T1 = (string | number | undefined) & (string | null | undefined); // string | undefined
>T1 : Symbol(T1, Decl(intersectionWithUnionConstraint.ts, 12, 1))
// Repro from #23648
type Example<T, U> = { [K in keyof T]: K extends keyof U ? UnexpectedError<K> : NoErrorHere<K> }
>Example : Symbol(Example, Decl(intersectionWithUnionConstraint.ts, 14, 70))
>T : Symbol(T, Decl(intersectionWithUnionConstraint.ts, 18, 13))
>U : Symbol(U, Decl(intersectionWithUnionConstraint.ts, 18, 15))
>K : Symbol(K, Decl(intersectionWithUnionConstraint.ts, 18, 24))
>T : Symbol(T, Decl(intersectionWithUnionConstraint.ts, 18, 13))
>K : Symbol(K, Decl(intersectionWithUnionConstraint.ts, 18, 24))
>U : Symbol(U, Decl(intersectionWithUnionConstraint.ts, 18, 15))
>UnexpectedError : Symbol(UnexpectedError, Decl(intersectionWithUnionConstraint.ts, 18, 96))
>K : Symbol(K, Decl(intersectionWithUnionConstraint.ts, 18, 24))
>NoErrorHere : Symbol(NoErrorHere, Decl(intersectionWithUnionConstraint.ts, 20, 47))
>K : Symbol(K, Decl(intersectionWithUnionConstraint.ts, 18, 24))
type UnexpectedError<T extends PropertyKey> = T
>UnexpectedError : Symbol(UnexpectedError, Decl(intersectionWithUnionConstraint.ts, 18, 96))
>T : Symbol(T, Decl(intersectionWithUnionConstraint.ts, 20, 21))
>PropertyKey : Symbol(PropertyKey, Decl(lib.d.ts, --, --))
>T : Symbol(T, Decl(intersectionWithUnionConstraint.ts, 20, 21))
type NoErrorHere<T extends PropertyKey> = T
>NoErrorHere : Symbol(NoErrorHere, Decl(intersectionWithUnionConstraint.ts, 20, 47))
>T : Symbol(T, Decl(intersectionWithUnionConstraint.ts, 21, 17))
>PropertyKey : Symbol(PropertyKey, Decl(lib.d.ts, --, --))
>T : Symbol(T, Decl(intersectionWithUnionConstraint.ts, 21, 17))

View File

@ -0,0 +1,83 @@
=== tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts ===
function f1<T extends string | number, U extends string | number>(x: T & U) {
>f1 : <T extends string | number, U extends string | number>(x: T & U) => void
>T : T
>U : U
>x : T & U
>T : T
>U : U
// Combined constraint of 'T & U' is 'string | number'
let y: string | number = x;
>y : string | number
>x : T & U
}
function f2<T extends string | number | undefined, U extends string | null | undefined>(x: T & U) {
>f2 : <T extends string | number | undefined, U extends string | null | undefined>(x: T & U) => void
>T : T
>U : U
>null : null
>x : T & U
>T : T
>U : U
let y1: string | number = x; // Error
>y1 : string | number
>x : T & U
let y2: string | null = x; // Error
>y2 : string | null
>null : null
>x : T & U
let y3: string | undefined = x;
>y3 : string | undefined
>x : T & U
let y4: number | null = x; // Error
>y4 : number | null
>null : null
>x : T & U
let y5: number | undefined = x; // Error
>y5 : number | undefined
>x : T & U
let y6: null | undefined = x; // Error
>y6 : null | undefined
>null : null
>x : T & U
}
type T1 = (string | number | undefined) & (string | null | undefined); // string | undefined
>T1 : string | undefined
>null : null
// Repro from #23648
type Example<T, U> = { [K in keyof T]: K extends keyof U ? UnexpectedError<K> : NoErrorHere<K> }
>Example : Example<T, U>
>T : T
>U : U
>K : K
>T : T
>K : K
>U : U
>UnexpectedError : T
>K : K
>NoErrorHere : T
>K : K
type UnexpectedError<T extends PropertyKey> = T
>UnexpectedError : T
>T : T
>PropertyKey : string | number | symbol
>T : T
type NoErrorHere<T extends PropertyKey> = T
>NoErrorHere : T
>T : T
>PropertyKey : string | number | symbol
>T : T