Skip to content

Commit

Permalink
[pickers] Fix DateBuilderReturnType when the date is undefined (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-kozlenkov authored May 27, 2024
1 parent 769b00e commit 36381a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/x-date-pickers/src/models/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export type AdapterOptions<TLocale, TInstance> = {
locale?: TLocale;
} & PropertyIfNotNever<'instance', TInstance>;

export type DateBuilderReturnType<T extends string | null | undefined, TDate> = T extends null
export type DateBuilderReturnType<T extends string | null | undefined, TDate> = [T] extends [null]
? null
: TDate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ export const testCalculations: DescribeGregorianAdapterTestSuite = ({
).to.be.lessThan(5);
}
});

it('should work without args', () => {
const date = adapter.date().valueOf();

expect(Math.abs(date - Date.now())).to.be.lessThan(5);
});
});

it('Method: getTimezone', () => {
Expand Down

0 comments on commit 36381a3

Please sign in to comment.