Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Note the new TS option for throwOnInvalid. #1415

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/validity.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ DateTime.now().setZone("America/Blorp"); //=> Error: Invalid DateTime: unsupport

You can of course leave this on in production too, but be sure to try/catch it appropriately.

For TypeScript users, this runtime setting narrows the return types. You need manually inform TypeScript of this setting with this snippet.
```ts
declare module 'luxon' {
interface TSSettings {
throwOnInvalid: true;
}
}
```
This will remove the null, etc. return types from getters/methods that would only do so for invalid objects.

## Invalid Durations

Durations can be invalid too. The easiest way to get one is to diff an invalid DateTime.
Expand Down