TypeScript/tests/cases/compiler/sourceMapValidationDestructuringForOfObjectBindingPattern.ts

68 lines
2.2 KiB
TypeScript

// @sourcemap: true
declare var console: {
log(msg: any): void;
}
interface Robot {
name: string;
skill: string;
}
interface MultiRobot {
name: string;
skills: {
primary: string;
secondary: string;
};
}
let robots: Robot[] = [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }];
let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }];
function getRobots() {
return robots;
}
function getMultiRobots() {
return multiRobots;
}
for (let {name: nameA } of robots) {
console.log(nameA);
}
for (let {name: nameA } of getRobots()) {
console.log(nameA);
}
for (let {name: nameA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) {
console.log(nameA);
}
for (let { skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) {
console.log(primaryA);
}
for (let { skills: { primary: primaryA, secondary: secondaryA } } of getMultiRobots()) {
console.log(primaryA);
}
for (let { skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) {
console.log(primaryA);
}
for (let {name: nameA, skill: skillA } of robots) {
console.log(nameA);
}
for (let {name: nameA, skill: skillA } of getRobots()) {
console.log(nameA);
}
for (let {name: nameA, skill: skillA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) {
console.log(nameA);
}
for (let {name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) {
console.log(nameA);
}
for (let {name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of getMultiRobots()) {
console.log(nameA);
}
for (let {name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) {
console.log(nameA);
}