microsoft / microsoft/TypeScript

Auto-imports don’t work in content-mappers without existing import

Đang mở
#64,119 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

@andrewbranch đang làm issue này rồi.

Từ ngày 1/9/2026.

Domain: Content Mappers Needs Investigation
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

### 🔎 Search Terms

`content-mapper`

### 🕗 Version & Regression Information

- I was unable to test this on prior versions because content mappers aren’t even released yet :)

### ⏯ Playground Link

n/a

### 💻 Code

https://github.com/remcohaszing/mdx-content-mapper/tree/auto-import-issue

Specifically, https://github.com/remcohaszing/mdx-content-mapper/commit/04037c2bd2d959adefd2d3f0b11a070139e5028d

### 🙁 Actual behavior

Automatic imports work, if the statement to insert it to is already present. However, if the import statement isn’t present yet, then TypeScript won’t generate the statement.

This works:

Image

This does not:

Image

### 🙂 Expected behavior

Automatic imports always work.

### Additional information about the issue

I tried to make this work by pushing an empty verbatim mapping to the start of the virtual content, like below. The virtual content may start with `'// @ts-check\n'`. In this case, the mapping is placed after that comment.

```js
let esm = checkMdx ? '// @ts-check\n' : ''
esmMappings.push([
0,
0,
esm.length,
0,
/** @satisfies {SpanMapKind.Verbatim} */ (0),
/** @satisfies {SpanMapFeature.AutoInsert} */ (131_072)
])
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.