microsoft / microsoft/TypeScript

Comment like jsx text emitted twice when preserve enabled

Open
#61,860 1 comment 0 reactions 0 assignees View on GitHub
Bug Domain: JSX/TSX Help Wanted
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### 🔎 Search Terms

comment like jsx text, preserve jsx

### 🕗 Version & Regression Information

- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________

### ⏯ Playground Link

https://www.typescriptlang.org/play/?jsx=1#code/GYVwdgxgLglg9mABAQQA6oBQEpEG8C+AUMRAgM5SIBWZAHogLyIA8aqAfAPQBUiYcibp1w9EARkGdxAJgDMiUdMn5R-Sc05t2AbkJA

### 💻 Code

```tsx
function App() {}
const jsx = /* no */{/* 1 */ 123 /* 2 */}/* no */;
```

### 🙁 Actual behavior

These duplicate sections will be rendered in the JSX text output:

```jsx
"use strict";
function App() { }
const jsx = /* no *//* no */{/* 1 */123 /* 2 */} /* no *//* no */
// ~~~~~~~ ~~~~~~~
```

### 🙂 Expected behavior

```diff
"use strict";
function App() { }
- const jsx = /* no *//* no */{/* 1 */123 /* 2 */} /* no *//* no */
+ const jsx = /* no */{/* 1 */123 /* 2 */} /* no */
```

### Additional information about the issue

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the linked TypeScript Playground and the TSX reproducer using preserve JSX handling. Compare the emitted JSX text with the expected output: each /* no */ comment should appear once rather than being duplicated.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.