mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add tests
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// @strict: true
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user