microsoft / microsoft/TypeScript

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

未关闭
#64,119 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@andrewbranch 已经在做这个了。

开始于 2026年9月1日。

Domain: Content Mappers Needs Investigation
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

🔎 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.

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。