File: destructuringParameterDeclaration8.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (70 lines) | stat: -rw-r--r-- 1,923 bytes parent folder | download | duplicates (4)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts ===
// explicit type annotation should cause `method` to have type 'x' | 'y'
// both inside and outside `test`.
function test({
>test : ({ method, nested: { p } }: {    method?: 'x' | 'y';    nested?: {        p: 'a' | 'b';    };}) => void

    method = 'z',
>method : "x" | "y"
>'z' : "z"

    nested: { p = 'c' }
>nested : any
>p : "a" | "b"
>'c' : "c"

}: {
    method?: 'x' | 'y',
>method : "x" | "y"

    nested?: { p: 'a' | 'b' }
>nested : { p: 'a' | 'b'; }
>p : "a" | "b"

})
{
    method
>method : "x" | "y"

    p
>p : "a" | "b"
}

test({});
>test({}) : void
>test : ({ method, nested: { p } }: { method?: "x" | "y"; nested?: { p: "a" | "b"; }; }) => void
>{} : {}

test({ method: 'x', nested: { p: 'a' } })
>test({ method: 'x', nested: { p: 'a' } }) : void
>test : ({ method, nested: { p } }: { method?: "x" | "y"; nested?: { p: "a" | "b"; }; }) => void
>{ method: 'x', nested: { p: 'a' } } : { method: "x"; nested: { p: "a"; }; }
>method : "x"
>'x' : "x"
>nested : { p: "a"; }
>{ p: 'a' } : { p: "a"; }
>p : "a"
>'a' : "a"

test({ method: 'z', nested: { p: 'b' } })
>test({ method: 'z', nested: { p: 'b' } }) : void
>test : ({ method, nested: { p } }: { method?: "x" | "y"; nested?: { p: "a" | "b"; }; }) => void
>{ method: 'z', nested: { p: 'b' } } : { method: "z"; nested: { p: "b"; }; }
>method : "z"
>'z' : "z"
>nested : { p: "b"; }
>{ p: 'b' } : { p: "b"; }
>p : "b"
>'b' : "b"

test({ method: 'one', nested: { p: 'a' } })
>test({ method: 'one', nested: { p: 'a' } }) : void
>test : ({ method, nested: { p } }: { method?: "x" | "y"; nested?: { p: "a" | "b"; }; }) => void
>{ method: 'one', nested: { p: 'a' } } : { method: "one"; nested: { p: "a"; }; }
>method : "one"
>'one' : "one"
>nested : { p: "a"; }
>{ p: 'a' } : { p: "a"; }
>p : "a"
>'a' : "a"