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
|
//// [contextuallyTypedBindingInitializerNegative.ts]
interface Show {
show: (x: number) => string;
}
function f({ show: showRename = v => v }: Show) {}
function f2({ "show": showRename = v => v }: Show) {}
function f3({ ["show"]: showRename = v => v }: Show) {}
interface Nested {
nested: Show
}
function ff({ nested: nestedRename = { show: v => v } }: Nested) {}
interface StringIdentity {
stringIdentity(s: string): string;
}
let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x};
interface Tuples {
prop: [string, number];
}
function g({ prop = [101, 1234] }: Tuples) {}
interface StringUnion {
prop: "foo" | "bar";
}
function h({ prop = "baz" }: StringUnion) {}
//// [contextuallyTypedBindingInitializerNegative.js]
function f(_a) {
var _b = _a.show, showRename = _b === void 0 ? function (v) { return v; } : _b;
}
function f2(_a) {
var _b = _a["show"], showRename = _b === void 0 ? function (v) { return v; } : _b;
}
function f3(_a) {
var _b = _a["show"], showRename = _b === void 0 ? function (v) { return v; } : _b;
}
function ff(_a) {
var _b = _a.nested, nestedRename = _b === void 0 ? { show: function (v) { return v; } } : _b;
}
var _a = { stringIdentity: function (x) { return x; } }.stringIdentity, id = _a === void 0 ? function (arg) { return arg.length; } : _a;
function g(_a) {
var _b = _a.prop, prop = _b === void 0 ? [101, 1234] : _b;
}
function h(_a) {
var _b = _a.prop, prop = _b === void 0 ? "baz" : _b;
}
|