Skip to content

[luxon] Export validity helper types from the barrel - #75463

Open
lazerg wants to merge 2 commits into
DefinitelyTyped:masterfrom
lazerg:luxon-export-validity-types
Open

lazerg wants to merge 2 commits into
DefinitelyTyped:masterfrom
lazerg:luxon-export-validity-types

Conversation

@lazerg

@lazerg lazerg commented Aug 31, 2026

Copy link
Copy Markdown

Valid, Invalid and DefaultValidity are the type arguments of the exported DateTime<IsValid>, Interval<IsValid> and Duration<IsValid> generics, but they live in src/_util.d.ts, which the barrel never re-exported. Until 3.7.0 you could still reach them through luxon/src/_util; the exports map added in #73292 closed that path, so there is now no way to name them.

This re-exports the five validity helpers from src/luxon.d.ts. Doing it that way keeps the exports map (and the arethetypeswrong fix) untouched, and doesn't expose the rest of the internals the way adding "./src/*" would.

Fixes #75462

Please fill in this template.

If changing an existing definition:

@typescript-automation

typescript-automation Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@lazerg Thank you for submitting this PR!

This is a live comment that I will keep updated.

1 package in this PR

Code Reviews

Because this is a widely-used package, a DT maintainer will need to review it before it can be merged.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • 🕐 Most recent commit is approved by a DT maintainer

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.

Inactive

This PR has been inactive for 16 days — please try to get reviewers!


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 75463,
  "author": "lazerg",
  "headCommitOid": "4384e33ce74b221408471891f18caa6f6d2d88cb",
  "mergeBaseOid": "d0ba4d27bbba786ca23dca88cf8878867a83ccb8",
  "lastPushDate": "2026-08-31T11:59:21.000Z",
  "lastActivityDate": "2026-09-14T17:34:55.000Z",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "tooManyCommits": false,
  "tooManyReviews": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "luxon",
      "version": "3.7",
      "kind": "edit",
      "files": [
        {
          "path": "types/luxon/src/luxon.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/luxon/test/luxon-tests.module.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "carsonf",
        "peterblazejewicz"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [],
  "mainBotCommentID": 5478008923,
  "ciResult": "pass"
}

@typescript-automation

Copy link
Copy Markdown
Contributor

🔔 @CarsonF @peterblazejewicz — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-automation typescript-automation Bot moved this to Waiting for Code Reviews in Pull Request Status Board Aug 31, 2026
@typescript-automation typescript-automation Bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board Aug 31, 2026
@typescript-automation typescript-automation Bot added the Where is GH Actions? GH Actions didn't give a response to this PR label Aug 31, 2026
@typescript-automation typescript-automation Bot moved this from Needs Maintainer Review to Other in Pull Request Status Board Aug 31, 2026
@typescript-automation typescript-automation Bot removed the Where is GH Actions? GH Actions didn't give a response to this PR label Aug 31, 2026
@typescript-automation typescript-automation Bot moved this from Other to Needs Maintainer Review in Pull Request Status Board Aug 31, 2026
@typescript-automation

Copy link
Copy Markdown
Contributor

Re-ping @CarsonF, @peterblazejewicz:

This PR has been out for over a week, yet I haven't seen any reviews.

Could someone please give it some attention? Thanks!

@typescript-automation typescript-automation Bot added the Unreviewed No one showed up to review this PR, so it'll be reviewed by a DT maintainer. label Sep 11, 2026
@CarsonF

CarsonF commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Sorry for the delay here.
What's your use case for using these types?
They were always meant to be private helpers (hence the leading underscore _util).

I can see how DateTime<Valid> is desired, but idk if it is worth this library exporting it. The main goal of doing it here, was to provide readability for those consuming these types.
You could still easily do

export type Valid = true;
// or
export type ValidDateTime = DateTime<true>;

FYI if you opted in to throw on invalid, you wouldn't have to worry about the validity conditions.

import { Settings } from 'luxon';

Settings.throwOnInvalid = true;

declare module 'luxon' {
  interface TSSettings {
    throwOnInvalid: true;
  }
}

// DateTime == DateTime<true>

@lazerg

lazerg commented Sep 14, 2026

Copy link
Copy Markdown
Author

You're right about Valid/Invalid. DateTime<true> already works, no need to export those.

DefaultValidity, CanBeInvalid, and IfValid are different: conditional types on TSSettings, not literals. You can rebuild them locally since TSSettings is public, but every package needing them has to reimplement all three. That's what the old _util deep import gave for free before #73292. throwOnInvalid only helps code that commits app-wide to throwing; it doesn't help a library that wants one helper working in both modes. The same generics show up on Interval, Duration, and Zone too, not just DateTime.

Happy to drop Valid/Invalid and trim the export to just those three.

@CarsonF

CarsonF commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Are you subclassing? what are some signatures that use these types?

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

Labels

Critical package Unreviewed No one showed up to review this PR, so it'll be reviewed by a DT maintainer.

Projects

Status: Needs Maintainer Review

Development

Successfully merging this pull request may close these issues.

[@types/luxon] Validity helper types (Valid, Invalid, DefaultValidity) are not importable after the 3.7.0 export map

2 participants