Allow content-mappers to return declarations instead of source files

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

@andrewbranch 已经在做这个了。

开始于 2026年9月8日。

评估

这个 Issue 还没有评估数据。

描述

Domain: Content Mappers
🔍 Search Terms

content mapper

✅ Viability Checklist
⭐ Suggestion

I would like to be able to opt out of lint-like TypeScript errors for content-mappers. For example, I might want to use ESM syntax in a CJS context, even if verbatimModuleSyntax is allowed. Or I would like to use export =, even is module is set to esnext.

A context where these rules don’t apply, are declaration files.

📃 Motivating Example

Content mapper authors can now return a .d.ts, .d.cts, or .d.mts extension as part of the transform response.

💻 Use Cases

I realized you can sort of categorize content mappers into two categories.

The first category is files with embedded JavaScript/TypeScript content. This includes Astro, Ember, MDX, Svelte, and Vue. This is the typical use case for content mappers. In this case it makes sense for the format to be opiniated about the module format.

The second category is static data that can be imported, but has a known shape. I just published css-modules-content-mapper. This always exports a value whose type matches Record<string, string>, but the keys are known. Other formats in this category are JSON5, TOML, YAML, XML, etc. These formats can always be written using type declarations only.

For this second category, I would really like to not care about the module format used. I want to use export = and tell TypeScript to treat it as a .d.${ext}.cts file.

A workaround is to add an @ts-ignore comment to the export = line, but that seems less ideal.

主要语言
Go
星标
111k
派生
14.4k
平均合并
1 天 15 小时
30 天内合并 PR
106

贡献指南

打开贡献指南

从这里开始

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

microsoft/TypeScript 的其他 Issue

查看 microsoft/TypeScript 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

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