Skip to content

Add support for TypeScript content mappers - #1978

Merged
webpro merged 3 commits into
webpro-nl:mainfrom
remcohaszing:typescript-content-mappers
Aug 28, 2026
Merged

webpro merged 3 commits into
webpro-nl:mainfrom
remcohaszing:typescript-content-mappers

Conversation

@remcohaszing

Copy link
Copy Markdown
Contributor

Hello from the future 👋

TypeScript 7.1 will add support for content mappers, allowing you to check files other than TypeScript, such as MDX, Vue, Ember, etc.

This change makes Knip understand the the package field in the contentMappers entries refers to an npm package name.

This feature is still experimental. The configuration might change before the TypeScript 7.1 releases, but I don’t expect any changes.

TypeScript 7.1 will add support for content mappers, allowing you to
check files other than TypeScript, such as MDX, Vue, Ember, etc.

This change makes Knip understand the the `package` field in the
`contentMappers` entries refers to an npm package name.
@pkg-pr-new

pkg-pr-new Bot commented Aug 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/knip@1978
npm i https://pkg.pr.new/@knip/language-server@1978
npm i https://pkg.pr.new/@knip/mcp@1978

commit: f1a9426

@webpro webpro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Before merge I'll double-check on their progress first, but this is almost good as-is, yet one remark I have.

Comment thread packages/knip/src/plugins/typescript/index.ts Outdated
@remcohaszing

Copy link
Copy Markdown
Contributor Author

I built mdx-content-mapper as a proof of concept and to provide feedback which helped shape the API. Content mappers have already been merged into the TypeScript main branch. I don’t expect the user-facing API to change, but there are no guarantees.

I think it would be nice if users can try this when TypeScript 7.1 (Beta? RC?) releases and Knip won’t complain about them adding content mapper dependencies.

See microsoft/TypeScript#63703 for the release schedule.

From the perspective of a content mapper implementation, it would be nice if Knip understands the package.json#/typescript/contentMapper/exec field, which defines a command to run. For example, see https://github.com/remcohaszing/mdx-content-mapper/blob/v0.0.1/package.json#L22-L25. This will of course only affect a tiny number of users, so it might not be worth the effort.

@webpro

webpro commented Aug 27, 2026

Copy link
Copy Markdown
Member

Content mappers have already been merged into the TypeScript main branch. I don't expect the user-facing API to change, but there are no guarantees.

I think it would be nice if users can try this when TypeScript 7.1 (Beta? RC?) releases and Knip won't complain about them adding content mapper dependencies.

Absolutely, happy to be on the forefront here. Let's make it happen.

@webpro

webpro commented Aug 27, 2026

Copy link
Copy Markdown
Member

From the perspective of a content mapper implementation, it would be nice if Knip understands the package.json#/typescript/contentMapper/exec field, which defines a command to run. For example, see https://github.com/remcohaszing/mdx-content-mapper/blob/v0.0.1/package.json#L22-L25. This will of course only affect a tiny number of users, so it might not be worth the effort.

I'll pick this up in the next day(s) too, seems trivial.

@remcohaszing
remcohaszing requested a review from webpro August 28, 2026 07:11
@webpro
webpro merged commit db67f9b into webpro-nl:main Aug 28, 2026
30 checks passed
@remcohaszing
remcohaszing deleted the typescript-content-mappers branch August 28, 2026 07:58
@webpro

webpro commented Aug 28, 2026

Copy link
Copy Markdown
Member

FYI, executed: 74640c0 (also some docs updated at 2bd3679).

@webpro

webpro commented Aug 28, 2026

Copy link
Copy Markdown
Member

🚀 This pull request is included in v6.33.0. See Release 6.33.0 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants