Skip to content

Commit 4c1f9cb

Browse files
committed
Add test case for #18634
1 parent 18962c1 commit 4c1f9cb

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

tests/baselines/reference/destructuredDeclarationEmit.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ const { bar: baz, bat, bam: { bork: { bar: ibar, baz: ibaz } } } = foo;
1212
export { baz, ibaz };
1313

1414
const [ , one, , [, bee, , [, {sec} ]]] = arr;
15-
export { one, bee, sec };
15+
export { one, bee, sec };
16+
17+
const getFoo = () => ({
18+
foo: 'foo'
19+
});
20+
21+
const { foo: foo2 } = getFoo();
22+
export { foo2 };
23+
1624

1725
//// [foo.js]
1826
"use strict";
@@ -34,6 +42,11 @@ var one = foo_1.arr[1], _b = foo_1.arr[3], bee = _b[1], _c = _b[3], sec = _c[1].
3442
exports.one = one;
3543
exports.bee = bee;
3644
exports.sec = sec;
45+
var getFoo = function () { return ({
46+
foo: 'foo'
47+
}); };
48+
var foo2 = getFoo().foo;
49+
exports.foo2 = foo2;
3750

3851

3952
//// [foo.d.ts]
@@ -60,3 +73,5 @@ declare const baz: string, ibaz: string;
6073
export { baz, ibaz };
6174
declare const one: 1, bee: "b", sec: "sec";
6275
export { one, bee, sec };
76+
declare const foo2: string;
77+
export { foo2 };

tests/baselines/reference/destructuredDeclarationEmit.symbols

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,19 @@ export { one, bee, sec };
5555
>bee : Symbol(bee, Decl(index.ts, 7, 13))
5656
>sec : Symbol(sec, Decl(index.ts, 7, 18))
5757

58+
const getFoo = () => ({
59+
>getFoo : Symbol(getFoo, Decl(index.ts, 9, 5))
60+
61+
foo: 'foo'
62+
>foo : Symbol(foo, Decl(index.ts, 9, 23))
63+
64+
});
65+
66+
const { foo: foo2 } = getFoo();
67+
>foo : Symbol(foo, Decl(index.ts, 9, 23))
68+
>foo2 : Symbol(foo2, Decl(index.ts, 13, 7))
69+
>getFoo : Symbol(getFoo, Decl(index.ts, 9, 5))
70+
71+
export { foo2 };
72+
>foo2 : Symbol(foo2, Decl(index.ts, 14, 8))
73+

tests/baselines/reference/destructuredDeclarationEmit.types

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,24 @@ export { one, bee, sec };
8080
>bee : "b"
8181
>sec : "sec"
8282

83+
const getFoo = () => ({
84+
>getFoo : () => { foo: string; }
85+
>() => ({ foo: 'foo'}) : () => { foo: string; }
86+
>({ foo: 'foo'}) : { foo: string; }
87+
>{ foo: 'foo'} : { foo: string; }
88+
89+
foo: 'foo'
90+
>foo : string
91+
>'foo' : "foo"
92+
93+
});
94+
95+
const { foo: foo2 } = getFoo();
96+
>foo : any
97+
>foo2 : string
98+
>getFoo() : { foo: string; }
99+
>getFoo : () => { foo: string; }
100+
101+
export { foo2 };
102+
>foo2 : string
103+

tests/cases/compiler/destructuredDeclarationEmit.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,11 @@ const { bar: baz, bat, bam: { bork: { bar: ibar, baz: ibaz } } } = foo;
1111
export { baz, ibaz };
1212

1313
const [ , one, , [, bee, , [, {sec} ]]] = arr;
14-
export { one, bee, sec };
14+
export { one, bee, sec };
15+
16+
const getFoo = () => ({
17+
foo: 'foo'
18+
});
19+
20+
const { foo: foo2 } = getFoo();
21+
export { foo2 };

0 commit comments

Comments
 (0)