File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
tests/cases/conformance/es6/destructuring Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ // @strict : true
2+
3+ function f1 ( obj : { a ?: string } ) {
4+ if ( obj . a ) {
5+ obj = { } ;
6+ let a1 = obj [ "a" ] ; // string | undefined
7+ let a2 = obj . a ; // string | undefined
8+ }
9+ }
10+
11+ function f2 ( obj : [ number , string ] | null [ ] ) {
12+ let a0 = obj [ 0 ] ; // number | null
13+ let a1 = obj [ 1 ] ; // string | null
14+ let [ b0 , b1 ] = obj ;
15+ ( [ a0 , a1 ] = obj ) ;
16+ if ( obj [ 0 ] && obj [ 1 ] ) {
17+ let c0 = obj [ 0 ] ; // number
18+ let c1 = obj [ 1 ] ; // string
19+ let [ d0 , d1 ] = obj ;
20+ ( [ c0 , c1 ] = obj ) ;
21+ }
22+ }
23+
24+ function f3 ( obj : { a ?: number , b ?: string } ) {
25+ if ( obj . a && obj . b ) {
26+ let { a, b } = obj ; // number, string
27+ ( { a, b } = obj ) ;
28+ }
29+ }
30+
31+ function f4 ( ) {
32+ let x : boolean ;
33+ ( { x } = 0 ) ; // Error
34+ ( { [ "x" ] : x } = 0 ) ; // Error
35+ ( { [ "x" + "" ] : x } = 0 ) ; // Errpr
36+ }
You can’t perform that action at this time.
0 commit comments