microsoft / microsoft/TypeScript

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

Abierto
#64,119 0 comentarios 0 reacciones 1 asignado Ver en GitHub

@andrewbranch ya está trabajando en esto.

Desde el 1/9/2026.

Domain: Content Mappers Needs Investigation
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

### 🔎 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)
])
```

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.