Repository navigation
feat: restamp tsc-copied declaration headers by default - #202
Merged
Merged
Conversation
For packages that build types/ in CI or prepack instead of committing it. With rewriteDeclarationCopies (--rewrite-declaration-copies), a .d.ts / .d.mts / .d.cts carrying tsc's copy of its own source's header is restamped instead of skipped: @filename and @project follow the path and package it ships in (a staged package folder with its own package.json is its own project root), and @Date, @author, @last modified by and @last modified time stay as the source's header has them. Skipping stays the default. Resolves #201
Generated declarations are what an IDE shows, so they get a header for the path and package they ship in by default. rewriteDeclarationCopies: false (--no-rewrite-declaration-copies) skips them, for repos that still commit types/; this repo sets it until its types/ moves out of git. Resolves #201
Shinrai
force-pushed
the
feat/generated-declarations
branch
from
November 25, 2026 21:54
e2b686d to
4e3edd7
Compare
A gitignored declaration counted as edited on every run, so a second run restamped it with the runner and the current time. A declaration git does not track that already has a header is now treated as generated and keeps the editor and dates it carries.
Shinrai
approved these changes
Nov 25, 2026
This was referenced Nov 25, 2026
Shinrai
added a commit
that referenced
this pull request
Nov 25, 2026
Release notes for v2.5.0: `docs/changelog/v2/v2.5.0.md` covering #202, and README What's New promoted to v2.5.0 (v2.4.0 moves into Recent Releases, v2.2.5 drops off).
cldmv-bot Bot
added a commit
that referenced
this pull request
Nov 25, 2026
# `@cldmv/fix-headers` v2.5.0 Changelog **Release Date**: November 2026 **Release Type**: Minor **Branch**: `release/2.5.0` --- ## Overview Generated TypeScript declarations get a header of their own. `tsc` copies a source file's header into the `.d.ts` / `.d.mts` / `.d.cts` it emits, so the declaration an IDE shows named the source file. fix-headers now restamps such a declaration for the path and package it ships in, keeping the source's dates and author. This is the setup for packages that build `types/` in CI or `prepack` instead of committing it. --- ## ✨ Features ### Generated declarations are restamped for where they ship ([#202](#202)) A declaration whose header names its own source (`types/src/x.d.mts` with `@Filename: src/x.mts`) gets `@Filename: types/src/x.d.mts` and its package's `@Project`. `@Date`, `@Author`, `@Last modified by` and `@Last modified time` stay as the source's header has them, since a generated file has no git history of its own. A staged package folder with its own `package.json` is its own project root, so `dist-packages/x-types/lib/x.d.mts` gets `@Filename: lib/x.d.mts` and that package's name. Run fix-headers after `tsc`, for example `fix-headers --input types` in `prepack` or CI. A later run leaves a restamped declaration as it is when git doesn't track it: a declaration with a header that git doesn't track is treated as generated, so it keeps the editor and dates it carries instead of taking the runner and the current time. `rewriteDeclarationCopies: false` (CLI `--no-rewrite-declaration-copies`) keeps the 2.4.0 behaviour of skipping these declarations, for repos that still commit `types/`. Fixes [#201](#201). ## 📚 Documentation - **NEW:** [docs/changelog/v2/v2.5.0.md](https://github.com/CLDMV/fix-headers/blob/v2.5.0/docs/changelog/v2/v2.5.0.md): this changelog. - README: the `rewriteDeclarationCopies` option and `--rewrite-declaration-copies` / `--no-rewrite-declaration-copies` flags, and the generated-declaration rule ([#202](#202)). - README What's New promoted to v2.5.0. ## 🔧 Dependencies _No dependency updates._ --- ## Upgrade notes - **Repos that commit generated `types/`:** set `"rewriteDeclarationCopies": false` in the fix-headers config. Otherwise fix-headers and `tsc` rewrite each other's `@Filename` on every build, as before 2.4.0. The better fix is to gitignore `types/` and build it in CI and `prepack`. - Repos that don't run fix-headers on declaration files see no change. <details> <summary>👥 Contributors</summary> - @Shinrai </details> --- <!-- coverage-start -->  | Metric | Coverage | |--------|----------| | Statements | 99.9% | | Branches | 98.9% | | Functions | 100.0% | | Lines | 99.9% | *Avg: **99.6%** · `9f69cbb` · 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.
Generated declarations are what an IDE shows, so a
.d.ts/.d.mts/.d.ctscarryingtsc's copy of its source's header now gets a header for where it ships:@Filename: types/src/x.d.mtsand that package's@Project. A staged package folder with its ownpackage.jsonis its own root, sodist-packages/x-types/lib/x.d.mtsgets@Filename: lib/x.d.mts.@Date,@Author,@Last modified byand@Last modified timeare kept from the source's header, and a later run leaves a restamped declaration that git doesn't track as it is, since the generated file has no git history.rewriteDeclarationCopies: false(--no-rewrite-declaration-copies) keeps the 2.4.0 skip for repos that still committypes/. This repo sets it until its owntypes/moves out of git.Resolves #201