Repository navigation
fix: leave declaration files that carry tsc's copy of the source header alone - #196
Merged
Merged
Conversation
…er alone tsc copies a source file's header into the .d.ts/.d.mts/.d.cts it emits, @filename included, so fix-headers and tsc kept rewriting each other's @filename on every run. The node detector now skips a declaration file whose header names its own source (x.d.mts from x.mts/x.mjs, x.d.ts from x.ts/x.tsx/x.js/x.jsx, x.d.cts from x.cts/x.cjs). Declarations with no header, or a header naming any other file, are fixed as before. Detectors' resolveContentSkipReason now also receives the file path. Resolves #195
Shinrai
approved these changes
Nov 25, 2026
This was referenced Nov 25, 2026
This was referenced Nov 25, 2026
Shinrai
added a commit
that referenced
this pull request
Nov 25, 2026
`@Filename` is the path relative to the project root, so it's now written as `src/index.mjs` instead of `/src/index.mjs`. A header with the old leading slash is rewritten on the next run and keeps its `@Last modified by`, so picking this up in a repo is a header-only change. README examples are updated to match. The declaration-copy check from #196 compares only the file name, so it works with both forms. The second commit restamps this repo's own headers with the new form. Resolves #198
Shinrai
added a commit
that referenced
this pull request
Nov 25, 2026
cldmv-bot Bot
added a commit
that referenced
this pull request
Nov 25, 2026
# `@cldmv/fix-headers` v2.4.0 Changelog **Release Date**: November 2026 **Release Type**: Minor **Branch**: `release/2.4.0` --- ## Overview `@Filename` is now written without a leading slash. It is the file's path relative to the project root, and `/src/index.mjs` read as an absolute path, so it is written as `src/index.mjs`. Headers written by earlier versions are rewritten on the next run. Declaration files that `tsc` emits with a copy of their source's header are now left alone, so `tsc` and fix-headers stop rewriting each other's `@Filename` in committed `types/` folders. --- ## ✨ Features ### `@Filename` without a leading slash ([#199](#199)) `src/index.mjs` → `@Filename: src/index.mjs` (was `/src/index.mjs`). A file with no project root above it gets just its file name. An existing header with the leading slash is rewritten on the next run like any other stale field: only the `@Filename` line and `@Last modified time` change, and the recorded `@Last modified by` is kept because the file's content was not edited. Fixes [#198](#198). ## 🐛 Bug Fixes ### Declarations carrying `tsc`'s copy of the source header are skipped ([#196](#196)) `tsc` copies a source file's leading comment into the `.d.ts` / `.d.mts` / `.d.cts` it emits, so a generated `types/src/x.d.mts` carried `@Filename` naming `src/x.mts`. fix-headers rewrote it to the declaration's own path, and the next `tsc` build wrote it back, so every build and every fix-headers run changed the committed declarations. A declaration whose header names its own source is now reported in `skipped` and left as `tsc` wrote it. The pairs are `x.d.mts` from `x.mts` / `x.mjs`, `x.d.ts` from `x.ts` / `x.tsx` / `x.js` / `x.jsx`, and `x.d.cts` from `x.cts` / `x.cjs`; the check compares file names only, so both the old slashed and the new `@Filename` form match. A declaration with no header, or one naming any other file (a hand-written declaration that was moved or renamed), is fixed as before. Fixes [#195](#195). ## 📚 Documentation - **NEW:** [docs/changelog/v2/v2.4.0.md](https://github.com/CLDMV/fix-headers/blob/v2.4.0/docs/changelog/v2/v2.4.0.md): this changelog. - README: every `@Filename` example uses the slashless form, the project-root rules say so, and the skip rules describe generated declaration files ([#196](#196), [#199](#199)). - README What's New promoted to v2.4.0. ## 🔧 Dependencies _No dependency updates._ --- ## Upgrade notes - The first run after upgrading rewrites the `@Filename` line (and `@Last modified time`) in every file that has a header. Land it on its own, as a header-only commit, when no open PRs touch the same files. - `@Last modified by` and `@Author` are kept on that run. - Generated declarations whose header names their own source now show up in `skipped`; nothing else about how declarations are handled changes. <details> <summary>👥 Contributors</summary> - @Shinrai </details> --- <!-- coverage-start -->  | Metric | Coverage | |--------|----------| | Statements | 99.9% | | Branches | 98.8% | | Functions | 100.0% | | Lines | 99.9% | *Avg: **99.6%** · `a32ffe5` · Node lts/** <!-- coverage-end --> <!-- co-authors --> Co-authored-by: Shinrai <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tsccopies a source file's header into the declaration it emits, so fix-headers andtsckept flipping@Filenamein committedtypes/. The node detector now skips a.d.ts/.d.mts/.d.ctswhose header names its own source (x.d.mts←x.mts/x.mjs,x.d.ts←x.ts/x.tsx/x.js/x.jsx,x.d.cts←x.cts/x.cjs). Declarations with no header, or one naming any other file, are fixed as before.Resolves #195