Files
tsgo/testdata/baselines/reference/compiler/optionalChainingArrowFunctionCommentEs2018.js
aeff766c31 Preserve comments when downleveling arrow expression bodies (#4723)
Co-authored-by: Jake Bailey <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
2026-08-19 20:30:16 +00:00

41 lines
1.9 KiB
TypeScript

//// [tests/cases/compiler/optionalChainingArrowFunctionCommentEs2018.ts] ////
//// [optionalChainingArrowFunctionCommentEs2018.ts]
const thing = { nested: { condition: true } };
const wat = () =>
// explanatory comment
thing?.nested?.condition ? "pass" : "fail";
const watInline = () => /* inline explanatory comment */ thing?.nested?.condition ? "pass" : "fail";
const watInlineMultiline = () => /* inline
explanatory comment */ thing?.nested?.condition ? "pass" : "fail";
const watInlineThenLeading = () => /* inline explanatory comment */
// leading explanatory comment
thing?.nested?.condition ? "pass" : "fail";
declare const o: { a?: number[] };
export const f = () =>
// comment
o.a?.length;
//// [optionalChainingArrowFunctionCommentEs2018.js]
const thing = { nested: { condition: true } };
const wat = () => { var _a;
// explanatory comment
return ((_a = thing === null || thing === void 0 ? void 0 : thing.nested) === null || _a === void 0 ? void 0 : _a.condition) ? "pass" : "fail"; };
const watInline = () => /* inline explanatory comment */ { var _a; /* inline explanatory comment */ return ((_a = thing === null || thing === void 0 ? void 0 : thing.nested) === null || _a === void 0 ? void 0 : _a.condition) ? "pass" : "fail"; };
const watInlineMultiline = () => /* inline
explanatory comment */ { var _a; /* inline
explanatory comment */ return ((_a = thing === null || thing === void 0 ? void 0 : thing.nested) === null || _a === void 0 ? void 0 : _a.condition) ? "pass" : "fail"; };
const watInlineThenLeading = () => /* inline explanatory comment */ { var _a; /* inline explanatory comment */
// leading explanatory comment
return ((_a = thing === null || thing === void 0 ? void 0 : thing.nested) === null || _a === void 0 ? void 0 : _a.condition) ? "pass" : "fail"; };
export const f = () => { var _a;
// comment
return (_a = o.a) === null || _a === void 0 ? void 0 : _a.length; };