Skip to content

Declarations tsc emits without the header get build-time dates #214

Done

Description

@Shinrai

tsc only copies a source's header into the declaration when it can keep the comment. When the header is followed by import lines, tsc moves the imports below the declarations and drops the header with them. In this repo that's 35 of the 38 files under types/src/; only files with no imports, such as utils/text.d.mts, keep the copy.

fix-headers then sees a headerless file and stamps it as new: @Date from the file's creation time and @Last modified time = now. Every types:build writes new times, so declarations built in CI or at prepack show the build time instead of the source's dates. The restamp from #201/#202 only covers declarations that still carry the source's header.

Expected: a headerless declaration whose source can be found takes that source's header dates and editor, the same as a copied one. Under the usual outDir layout types/src/x.d.mts comes from src/x.mjs (.d.ts ← .ts .tsx .js .jsx, .d.cts ← .cts .cjs). How fix-headers finds the source (a path rule, or reading rootDir/outDir from a tsconfig) needs deciding.

Repro: on next after #211, run npm run types:build twice; every declaration with imports changes only in @Last modified time.

Activity

  1. added
    type: bug
    priority: low
    status: confirmed
    area: core
    on Nov 27, 2026
  2. Shinrai commented on Nov 27, 2026

    @Shinrai
    ContributorAuthor

    Decision:

    • Find a declaration's source from the tsconfig it was built with: rootDir, outDir and declarationDir if set, following extends. types/src/x.d.mts maps back to <rootDir>/src/x.mts (or the .mjs / .ts sibling), so any layout works, not just a fixed path rule. A tsconfig option points at the file, defaulting to .configs/tsconfig.json and then ./tsconfig.json.
    • @Filename stays the declaration that ships (types/src/x.d.mts), never the source path. The source is only used to recover @Date, @Author and the rest of the original header when tsc dropped it, so the declaration isn't stamped as new with the build time.

    Doing it as its own PR after #215 merges.

  3. added a commit that references this issue on Nov 27, 2026
  4. added
    status: in progress
    and removed
    status: confirmed
    on Nov 27, 2026
  5. added a commit that references this issue on Nov 27, 2026
    ffc4e24
  6. removed
    status: in progress
    on Nov 27, 2026
  7. cldmv-bot commented on Nov 27, 2026

    @cldmv-bot
    Contributor

    Marked status: implemented — resolved by #218, merged into next. This issue closes automatically when that work ships to the default branch.

  8. added
    status: implemented
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corepriority: lowstatus: implementedtype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions