TypeScript/tests/baselines/reference/destructuringCatch.js
Wesley Wigham 1c93744a9c
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers

* Improved comments/sourcemaps for await, yield, while, and for

* Retain comments on block curly-braces

* Emit comments for if statements

* Improved switch case comment emit

* Improve comment and sourcemap emit for try/catch, throw, and continue statements

* Improve sourcemap emit and comments for with statements

* More accurate sourcemaps+comments emit for new, typeof, void, and delete

* Improve comment emit for element access expressions

* Preserve more comments on imports and exports

* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition

* Support preserving comments within empty lists

* Handle leading comments of tokens, conditionally indent leading comments

* Stop heuristically sourcemapping tokens

When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers

* Fix unneeded +1

* Tighten up element access comments

* Handle comments on parenthesized expression tokens

* Fix nit
2018-03-02 17:23:59 -08:00

59 lines
821 B
TypeScript

//// [destructuringCatch.ts]
try {
throw [0, 1];
}
catch ([a, b]) {
a + b;
}
try {
throw { a: 0, b: 1 };
}
catch ({a, b}) {
a + b;
}
try {
throw [{ x: [0], z: 1 }];
}
catch ([{x: [y], z}]) {
y + z;
}
// Test of comment ranges. A fix to GH#11755 should update this.
try {
}
catch (/*Test comment ranges*/[/*a*/a]) {
}
//// [destructuringCatch.js]
try {
throw [0, 1];
}
catch (_a) {
var a = _a[0], b = _a[1];
a + b;
}
try {
throw { a: 0, b: 1 };
}
catch (_b) {
var a = _b.a, b = _b.b;
a + b;
}
try {
throw [{ x: [0], z: 1 }];
}
catch (_c) {
var _d = _c[0], y = _d.x[0], z = _d.z;
y + z;
}
// Test of comment ranges. A fix to GH#11755 should update this.
try {
}
catch ( /*Test comment ranges*/_e) {
var /*a*/ a = _e[0];
}