File: parameterInitializersForwardReferencing1.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 (100 lines) | stat: -rw-r--r-- 1,786 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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
=== tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts ===
let foo: string = "";
>foo : string
>"" : ""

function f1 (bar = foo) { // unexpected compiler error; works at runtime
>f1 : (bar?: number) => number
>bar : number
>foo : number

    var foo: number = 2;
>foo : number
>2 : 2

    return bar; // returns 1
>bar : number
}

function f2 (bar = (baz = foo) => baz) { // unexpected compiler error; works at runtime
>f2 : (bar?: (baz?: number) => number) => number
>bar : (baz?: number) => number
>(baz = foo) => baz : (baz?: number) => number
>baz : number
>foo : number
>baz : number

    var foo: number = 2;
>foo : number
>2 : 2

    return bar(); // returns 1
>bar() : number
>bar : (baz?: number) => number
}

function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime
>f3 : (bar?: number, foo?: number) => number
>bar : number
>foo : number
>foo : number
>2 : 2

    return bar;
>bar : number
}

function f4 (foo, bar = foo) {
>f4 : (foo: any, bar?: any) => any
>foo : any
>bar : any
>foo : any

    return bar
>bar : any
}

function f5 (a = a) {
>f5 : (a?: any) => any
>a : any
>a : any

    return a
>a : any
}

function f6 (async = async) {
>f6 : (async?: any) => any
>async : any
>async : any

    return async
>async : any
}

function f7({[foo]: bar}: any[]) {
>f7 : ({ [foo]: bar }: any[]) => void
>foo : number
>bar : any

    let foo: number = 2;
>foo : number
>2 : 2
}

class Foo {
>Foo : Foo

    constructor(public x = 12, public y = x) {}
>x : number
>12 : 12
>y : number
>x : number
}

function f8(foo1: string, bar = foo1) { }
>f8 : (foo1: string, bar?: string) => void
>foo1 : string
>bar : string
>foo1 : string