File: nonPrimitiveAndTypeVariables.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (36 lines) | stat: -rw-r--r-- 700 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts ===
// Repros from #23800

type A<T, V> = { [P in keyof T]: T[P] extends V ? 1 : 0; };
>A : A<T, V>

type B<T, V> = { [P in keyof T]: T[P] extends V | object ? 1 : 0; };
>B : B<T, V>

let a: A<{ a: 0 | 1 }, 0> = { a: 0 };
>a : A<{ a: 0 | 1; }, 0>
>a : 0 | 1
>{ a: 0 } : { a: 0; }
>a : 0
>0 : 0

let b: B<{ a: 0 | 1 }, 0> = { a: 0 };
>b : B<{ a: 0 | 1; }, 0>
>a : 0 | 1
>{ a: 0 } : { a: 0; }
>a : 0
>0 : 0

function foo<T, U>(x: T) {
>foo : <T, U>(x: T) => void
>x : T

    let a: object = x;  // Error
>a : object
>x : T

    let b: U | object = x;  // Error
>b : object | U
>x : T
}