|
| 1 | +=== tests/cases/compiler/optionalParameterInDestructuringWithInitializer.ts === |
| 2 | +// https://github.com/Microsoft/TypeScript/issues/17080 |
| 3 | +function f(a:number,b:number) { |
| 4 | +>f : Symbol(f, Decl(optionalParameterInDestructuringWithInitializer.ts, 0, 0)) |
| 5 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 1, 11)) |
| 6 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 1, 20)) |
| 7 | +} |
| 8 | + |
| 9 | +function func1( {a, b}: {a: number, b?: number} = {a: 1, b: 2} ) { |
| 10 | +>func1 : Symbol(func1, Decl(optionalParameterInDestructuringWithInitializer.ts, 2, 1)) |
| 11 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 4, 17)) |
| 12 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 4, 19)) |
| 13 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 4, 25)) |
| 14 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 4, 35)) |
| 15 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 4, 51)) |
| 16 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 4, 56)) |
| 17 | + |
| 18 | + f(a, b) |
| 19 | +>f : Symbol(f, Decl(optionalParameterInDestructuringWithInitializer.ts, 0, 0)) |
| 20 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 4, 17)) |
| 21 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 4, 19)) |
| 22 | + |
| 23 | + // error |
| 24 | +} |
| 25 | + |
| 26 | +function func2( {a, b = 3}: {a: number, b?:number} = {a: 1,b: 2} ) { |
| 27 | +>func2 : Symbol(func2, Decl(optionalParameterInDestructuringWithInitializer.ts, 7, 1)) |
| 28 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 9, 17)) |
| 29 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 9, 19)) |
| 30 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 9, 29)) |
| 31 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 9, 39)) |
| 32 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 9, 54)) |
| 33 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 9, 59)) |
| 34 | + |
| 35 | + f(a, b) |
| 36 | +>f : Symbol(f, Decl(optionalParameterInDestructuringWithInitializer.ts, 0, 0)) |
| 37 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 9, 17)) |
| 38 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 9, 19)) |
| 39 | + |
| 40 | + // no error |
| 41 | +} |
| 42 | + |
| 43 | +function func3( {a, b}: {a: number, b?: number} = {a: 1} ) { |
| 44 | +>func3 : Symbol(func3, Decl(optionalParameterInDestructuringWithInitializer.ts, 12, 1)) |
| 45 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 14, 17)) |
| 46 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 14, 19)) |
| 47 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 14, 25)) |
| 48 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 14, 35)) |
| 49 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 14, 51)) |
| 50 | + |
| 51 | + f(a,b) |
| 52 | +>f : Symbol(f, Decl(optionalParameterInDestructuringWithInitializer.ts, 0, 0)) |
| 53 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 14, 17)) |
| 54 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 14, 19)) |
| 55 | + |
| 56 | + // error |
| 57 | +} |
| 58 | + |
| 59 | +function func4( {a: {b, c}, d}: {a: {b: number,c?: number},d: number} = {a: {b: 1,c: 2},d: 3} ) { |
| 60 | +>func4 : Symbol(func4, Decl(optionalParameterInDestructuringWithInitializer.ts, 17, 1)) |
| 61 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 33)) |
| 62 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 21)) |
| 63 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 23)) |
| 64 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 27)) |
| 65 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 33)) |
| 66 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 37)) |
| 67 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 47)) |
| 68 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 59)) |
| 69 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 73)) |
| 70 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 77)) |
| 71 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 82)) |
| 72 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 88)) |
| 73 | + |
| 74 | + f(b,c) |
| 75 | +>f : Symbol(f, Decl(optionalParameterInDestructuringWithInitializer.ts, 0, 0)) |
| 76 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 21)) |
| 77 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 19, 23)) |
| 78 | + |
| 79 | + // error |
| 80 | +} |
| 81 | + |
| 82 | +function func5({a: {b, c = 4}, d}: {a: {b: number,c?: number},d: number} = {a: {b: 1,c: 2},d: 3} ) { |
| 83 | +>func5 : Symbol(func5, Decl(optionalParameterInDestructuringWithInitializer.ts, 22, 1)) |
| 84 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 36)) |
| 85 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 20)) |
| 86 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 22)) |
| 87 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 30)) |
| 88 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 36)) |
| 89 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 40)) |
| 90 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 50)) |
| 91 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 62)) |
| 92 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 76)) |
| 93 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 80)) |
| 94 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 85)) |
| 95 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 91)) |
| 96 | + |
| 97 | + f(b, c) |
| 98 | +>f : Symbol(f, Decl(optionalParameterInDestructuringWithInitializer.ts, 0, 0)) |
| 99 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 20)) |
| 100 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 24, 22)) |
| 101 | + |
| 102 | + // no error |
| 103 | +} |
| 104 | + |
| 105 | +function func6( {a: {b, c} = {b: 4, c: 5}, d}: {a: {b: number, c?: number}, d: number} = {a: {b: 1,c: 2}, d: 3} ) { |
| 106 | +>func6 : Symbol(func6, Decl(optionalParameterInDestructuringWithInitializer.ts, 27, 1)) |
| 107 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 48)) |
| 108 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 21)) |
| 109 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 23)) |
| 110 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 30)) |
| 111 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 35)) |
| 112 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 42)) |
| 113 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 48)) |
| 114 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 52)) |
| 115 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 62)) |
| 116 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 75)) |
| 117 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 90)) |
| 118 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 94)) |
| 119 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 99)) |
| 120 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 105)) |
| 121 | + |
| 122 | + f(b, c) |
| 123 | +>f : Symbol(f, Decl(optionalParameterInDestructuringWithInitializer.ts, 0, 0)) |
| 124 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 21)) |
| 125 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 29, 23)) |
| 126 | + |
| 127 | + // error |
| 128 | +} |
| 129 | + |
| 130 | +function func7( {a: {b, c = 6} = {b: 4, c: 5}, d}: {a: {b: number, c?: number}, d: number} = {a: {b: 1, c: 2}, d: 3} ) { |
| 131 | +>func7 : Symbol(func7, Decl(optionalParameterInDestructuringWithInitializer.ts, 32, 1)) |
| 132 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 52)) |
| 133 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 21)) |
| 134 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 23)) |
| 135 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 34)) |
| 136 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 39)) |
| 137 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 46)) |
| 138 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 52)) |
| 139 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 56)) |
| 140 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 66)) |
| 141 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 79)) |
| 142 | +>a : Symbol(a, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 94)) |
| 143 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 98)) |
| 144 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 103)) |
| 145 | +>d : Symbol(d, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 110)) |
| 146 | + |
| 147 | + f(b, c) |
| 148 | +>f : Symbol(f, Decl(optionalParameterInDestructuringWithInitializer.ts, 0, 0)) |
| 149 | +>b : Symbol(b, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 21)) |
| 150 | +>c : Symbol(c, Decl(optionalParameterInDestructuringWithInitializer.ts, 34, 23)) |
| 151 | + |
| 152 | + // no error |
| 153 | +} |
| 154 | + |
0 commit comments