File: typeArgInferenceWithNull.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 (44 lines) | stat: -rw-r--r-- 1,145 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
37
38
39
40
41
42
43
44
=== tests/cases/compiler/typeArgInferenceWithNull.ts ===
// All legal

function fn4<T extends string>(n: T) { }
>fn4 : <T extends string>(n: T) => void
>n : T

fn4(null);
>fn4(null) : void
>fn4 : <T extends string>(n: T) => void
>null : null

function fn5<T extends { x: string }>(n: T) { }
>fn5 : <T extends { x: string; }>(n: T) => void
>x : string
>n : T

fn5({ x: null });
>fn5({ x: null }) : void
>fn5 : <T extends { x: string; }>(n: T) => void
>{ x: null } : { x: null; }
>x : null
>null : null

function fn6<T extends { x: string }>(n: T, fun: (x: T) => void, n2: T) { }
>fn6 : <T extends { x: string; }>(n: T, fun: (x: T) => void, n2: T) => void
>x : string
>n : T
>fun : (x: T) => void
>x : T
>n2 : T

fn6({ x: null }, y => { }, { x: "" }); // y has type { x: any }, but ideally would have type { x: string }
>fn6({ x: null }, y => { }, { x: "" }) : void
>fn6 : <T extends { x: string; }>(n: T, fun: (x: T) => void, n2: T) => void
>{ x: null } : { x: null; }
>x : null
>null : null
>y => { } : (y: { x: string; }) => void
>y : { x: string; }
>{ x: "" } : { x: string; }
>x : string
>"" : ""