[microsoft/TypeScript] Incorrect compile result of arrow function using implicit return (starts with optional chaining) and with line comments in between (#41814)

<!-- 🚨 STOP 🚨 STOP 🚨 STOP 🚨 Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section! Please help us by doing the following steps before logging an issue: * Search: https://github.com/Microsoft/TypeScript/search?type=Issues * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ Please fill in the *entire* template below. --> <!-- Please try to reproduce the issue with the latest published version. It may have already been fixed. For npm: `typescript@next` This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly --> **TypeScript Version:** Since v3.8.3 **Search Terms:** Arrow function, implicit return, line comments, optional chaining **Code** ```ts // Target: ES5 // arrow function, implicit return on 2nd line that starts with optional chaining, and has a line comment in between the lines. const test = (names: string[]) => // testing 1 two names?.filter(x => x); console.log(test(["a"])); ``` **Expected behavior:** Something like: ```ts "use strict"; var test = function (names) { // testing 1 two return names === null || names === void 0 ? void 0 : names.filter(function (x) { return x; }); }; console.log(test(["a"])); ``` **Actual behavior:** 1. the comment is being copied 3 times. 1. the first line comment terminates the `return`, making this function always return `undefined`. ```ts "use strict"; var test = function (names) { return // testing 1 two names === null || // testing 1 two names === void 0 ? void 0 : // testing 1 two names.filter(function (x) { return x; }); }; console.log(test(["a"])); ``` **Playground Link:** https://www.typescriptlang.org/play?target=1&ts=3.8.3#code/MYewdgzgLgBFCm0YF4YAowEMC2iBcM0ATgJZgDmA2gLoCUKAfDAFAxswD0HciUZ5MAIxwA7iFbssuCAH4AdADMSAGwRE0AD0YwNtANzNmoSCGXw5ykOTQJoaSgCJMDuvqA **Related Issues:**

Related Topics: TypeScript
  • アロー関数とコメントとoptional chainingでTypeScriptのトランスパイル結果を壊せるというHigh Priorityバグ。自分がこれ踏んだら調査にけっこう時間を溶かしそう。