Skip to content

Loosen getMinDate/getMaxDate date utils types for spread usage #17858

@RyanThomas73

Description

@RyanThomas73

What happened?

The typescript typing definitions for the date utils getMaxDate and getMinDate functions are incorrect. As a result, using these functions in typescript with a spread operator raises a TS2556 error.

The typings should not require the first date argument be passed separately from the remainder and should instead define a single rest parameters. i.e.

  function getMaxDate(
    ...args: (Date | number | string)[]
  ): Date;
  function getMinDate(
    ...args: (Date | number | string)[]
  ): Date;

What did you expect to happen?

The getMaxDate and getMinDate utility functions can be used with an array spread operator, as shown in the docs, without causing the incorrect typescript compiler TS2556 error.

Reproduction URL

https://jsfiddle.net/zp29djhy/1/

How to reproduce?

  1. Setup a project including quasar and typescript
  2. In a typescript file include the following code using a spread operator with getMaxDate
import { date } from 'quasar';
const exampleDates: Date[] = [ new Date(2025, 1, 25, 10, 30), new Date(2025, 1, 26, 10, 30), new Date(2025, 1, 27, 10, 30) ];
const maxDate = date.getMaxDate(...exampleDates);
  1. Run the typescript compiler to type check for errors. The ...exampleDates spread will raise a TS2556 error.

NOTE: I include a jsFiddle link with this code since the issue template says it is required, but this is a build time issue not a runtime issue so the bug is not reflected in the jsfiddle itself.

Flavour

Vite Plugin (@quasar/vite-plugin)

Areas

TypeScript Support

Platforms/Browsers

No response

Quasar info output

Relevant log output

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions