Skip to content

Commit d5e45d8

Browse files
IlCallorstoenescu
authored andcommitted
feat(typescript): enhance typings (quasarframework#5725)
1 parent cfa7185 commit d5e45d8

File tree

5 files changed

+51
-43
lines changed

5 files changed

+51
-43
lines changed

ui/types/utils.d.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ export * from './utils/event';
77

88
// others utils
99
export function openURL(url: string): void;
10-
export function debounce(fn: Function, wait?: Number, immediate?: boolean) : Function
11-
export function extend(...args: any[]): any;
12-
export function throttle(fn: Function, limit: Number): Function;
10+
export function debounce<F extends (...args: any[]) => any>(
11+
fn: F,
12+
wait?: number,
13+
immediate?: boolean
14+
): F;
15+
export function extend<R>(deep: boolean, target: any, ...sources: any[]): R;
16+
export function extend<R>(target: object, ...sources: any[]): R;
17+
export function throttle<F extends (...args: any[]) => any>(
18+
fn: F,
19+
limit: number
20+
): F;
1321
export function uid(): string;

ui/types/utils/colors.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export namespace colors {
1616
function rgbToHex(rgb: colorsRgba): string;
1717
// function rgbToString (color: colorsRgba): string;
1818
function hexToRgb(hex: string): colorsRgba;
19-
function hsvToRgb(hsv: colorsHsva) : colorsRgba;
20-
function rgbToHsv(rgb: colorsRgba) : colorsHsva;
21-
function textToRgb(color: string) : colorsRgba;
22-
function lighten(color: string, percent: number) : string;
23-
function luminosity(color: string | colorsRgba) : number;
24-
function setBrand(color: string, value: string, element?: Element) : void;
25-
function getBrand(color: string, element?: Element) : string;
19+
function hsvToRgb(hsv: colorsHsva): colorsRgba;
20+
function rgbToHsv(rgb: colorsRgba): colorsHsva;
21+
function textToRgb(color: string): colorsRgba;
22+
function lighten(color: string, percent: number): string;
23+
function luminosity(color: string | colorsRgba): number;
24+
function setBrand(color: string, value: string, element?: Element): void;
25+
function getBrand(color: string, element?: Element): string | null;
2626
}

ui/types/utils/date.d.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ export interface DateLocale {
2727
export type DateUnitOptions = "second" | "minute" | "hour" | "day" | "month" | "year";
2828

2929
export namespace date {
30-
function isValid(date: string): boolean;
30+
function isValid(date: number | string): boolean;
3131
function extractDate(str: string, mask: string, locale?: DateLocale): Date;
3232
function buildDate(options: BuildDateOptions, utc?: boolean): string;
33-
function getDayOfWeek(date: Date | number | string | number): number;
34-
function getWeekOfYear (date: Date | number | string) : number;
35-
function isBetweenDates (date: Date | number | string, from: Date, to: Date, opts? : { inclusiveFrom: boolean, inclusiveTo: boolean}) : boolean;
33+
function getDayOfWeek(date: Date | number | string): number;
34+
function getWeekOfYear(date: Date | number | string): number;
35+
function isBetweenDates(date: Date | number | string, from: Date | number | string, to: Date | number | string, opts?: { inclusiveFrom: boolean; inclusiveTo: boolean }): boolean;
3636
function addToDate(date: Date | number | string, options: ModifyDateOptions): Date;
3737
function subtractFromDate(date: Date | number | string, options: ModifyDateOptions): Date;
38-
function adjustDate (date: Date | number | string, options: ModifyDateOptions, utc?: boolean) : Date;
39-
function startOfDate(date: Date | number | string, option: DateUnitOptions) : Date;
40-
function endOfDate(date: Date | number | string, option: DateUnitOptions) : Date;
41-
function getMaxDate (date: Date | number | string, ...args: (Date | number | string)[]) : Date;
42-
function getMinDate (date: Date | number | string, ...args: (Date | number | string)[]) : Date;
43-
function getDateDiff (date: Date | number | string, subtract: Date | number | string, unit?: string) : Date;
44-
function getDayOfYear (date: Date | number | string) : number;
45-
function inferDateFormat (date: any) : string;
46-
function getDateBetween (date: Date | number | string, min: Date | number | string, max: Date | number | string) : Date
47-
function isSameDate (date: Date | number | string, date2: Date | number | string, unit?: string) : boolean;
48-
function daysInMonth (date: Date | number | string) : number;
38+
function adjustDate(date: Date | number | string, options: ModifyDateOptions, utc?: boolean): Date;
39+
function startOfDate(date: Date | number | string, option: DateUnitOptions): Date;
40+
function endOfDate(date: Date | number | string, option: DateUnitOptions): Date;
41+
function getMaxDate(date: Date | number | string, ...args: (Date | number | string)[]): Date;
42+
function getMinDate(date: Date | number | string, ...args: (Date | number | string)[]): Date;
43+
function getDateDiff(date: Date | number | string, subtract: Date | number | string, unit?: string): Date;
44+
function getDayOfYear(date: Date | number | string): number;
45+
function inferDateFormat(date: Date | number | string): "date" | "number" | "string";
46+
function getDateBetween(date: Date | number | string, min?: Date | number | string, max?: Date | number | string): Date;
47+
function isSameDate(date: Date | number | string, date2: Date | number | string, unit?: DateUnitOptions): boolean;
48+
function daysInMonth(date: Date | number | string): number;
4949
function formatDate(date: Date | number | string | undefined, format: string, locale?: DateLocale, __forcedYear?: number): string;
50-
function clone (date: Date) : Date;
50+
function clone<D extends Date | number | string>(date: D): D;
5151
}

ui/types/utils/dom.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ export interface DomOffset {
44
}
55

66
export namespace dom {
7-
function offset(el: Element) : DomOffset
8-
function style(el: Element, property: string) : string;
9-
function height(el: Element) : number;
10-
function width(el: Element) : number;
11-
function css(el: Element, css: any) : void;
12-
function cssBatch(elements: Element[], css: any) : void;
13-
function ready(fn: Function) : any;
7+
function offset(el: Element): DomOffset;
8+
function style(el: Element, property: string): string;
9+
function height(el: Element): number;
10+
function width(el: Element): number;
11+
function css(el: Element, css: Partial<CSSStyleDeclaration>): void;
12+
function cssBatch(elements: Element[], css: Partial<CSSStyleDeclaration>): void;
13+
function ready(fn: Function): any;
1414
}

ui/types/utils/scroll.d.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
export namespace scroll {
2-
function getScrollTarget(el: Element | Window): Element;
2+
function getScrollTarget(el: HTMLElement): HTMLElement | Window;
33

4-
function getScrollHeight(el: Element | Window): number;
5-
function getScrollWidth(el: Element | Window): number;
4+
function getScrollHeight(el: HTMLElement | Window): number;
5+
function getScrollWidth(el: HTMLElement | Window): number;
66

7-
function getScrollPosition(scrollTarget: Element | Window): number;
8-
function getHorizontalScrollPosition(scrollTarget: Element | Window): number;
7+
function getScrollPosition(scrollTarget: HTMLElement | Window): number;
8+
function getHorizontalScrollPosition(scrollTarget: HTMLElement | Window): number;
99

10-
function animScrollTo(el: Element | Window, to: number, duration: number): void;
11-
function animHorizontalScrollTo(el: Element | Window, to: number, duration: number): void;
10+
function animScrollTo(el: HTMLElement | Window, to: number, duration: number): void;
11+
function animHorizontalScrollTo(el: HTMLElement | Window, to: number, duration: number): void;
1212

13-
function setScrollPosition(scrollTarget: Element | Window, offset: number, duration?: number): void;
14-
function setHorizontalScrollPosition(scrollTarget: Element | Window, offset: number, duration?: number): void;
13+
function setScrollPosition(scrollTarget: HTMLElement | Window, offset: number, duration?: number): void;
14+
function setHorizontalScrollPosition(scrollTarget: HTMLElement | Window, offset: number, duration?: number): void;
1515

1616
function getScrollbarWidth(): number;
17-
function hasScrollbar(el: Element | Window, onY?: boolean): boolean;
17+
function hasScrollbar(el: HTMLElement | Window, onY?: boolean): boolean;
1818
}

0 commit comments

Comments
 (0)