File: destructuringParameterDeclaration8.js

package info (click to toggle)
node-typescript 5.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 497,488 kB
  • sloc: javascript: 2,107,274; makefile: 6; sh: 1
file content (35 lines) | stat: -rw-r--r-- 987 bytes parent folder | download
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
//// [tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts] ////

//// [destructuringParameterDeclaration8.ts]
// explicit type annotation should cause `method` to have type 'x' | 'y'
// both inside and outside `test`.
function test({
    method = 'z',
    nested: { p = 'c' }
}: {
    method?: 'x' | 'y',
    nested?: { p: 'a' | 'b' }
})
{
    method
    p
}

test({});
test({ method: 'x', nested: { p: 'a' } })
test({ method: 'z', nested: { p: 'b' } })
test({ method: 'one', nested: { p: 'a' } })


//// [destructuringParameterDeclaration8.js]
// explicit type annotation should cause `method` to have type 'x' | 'y'
// both inside and outside `test`.
function test(_a) {
    var _b = _a.method, method = _b === void 0 ? 'z' : _b, _c = _a.nested.p, p = _c === void 0 ? 'c' : _c;
    method;
    p;
}
test({});
test({ method: 'x', nested: { p: 'a' } });
test({ method: 'z', nested: { p: 'b' } });
test({ method: 'one', nested: { p: 'a' } });