Resolve warnings from typings (#9363)

This commit is contained in:
Jukka Kurkela 2021-07-09 14:03:11 +03:00 committed by GitHub
parent 774c444cb9
commit d661bd788b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 33 deletions

6
types/adapters.d.ts vendored
View File

@ -3,7 +3,7 @@ export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'w
export interface DateAdapter { export interface DateAdapter {
// Override one or multiple of the methods to adjust to the logic of the current date library. // Override one or multiple of the methods to adjust to the logic of the current date library.
override(members: Partial<DateAdapter>): void; override(members: Partial<DateAdapter>): void;
readonly options: any; readonly options: unknown;
/** /**
* Returns a map of time formats for the supported formatting units defined * Returns a map of time formats for the supported formatting units defined
@ -13,10 +13,10 @@ export interface DateAdapter {
formats(): { [key: string]: string }; formats(): { [key: string]: string };
/** /**
* Parses the given `value` and return the associated timestamp. * Parses the given `value` and return the associated timestamp.
* @param {any} value - the value to parse (usually comes from the data) * @param {unknown} value - the value to parse (usually comes from the data)
* @param {string} [format] - the expected data format * @param {string} [format] - the expected data format
*/ */
parse(value: any, format?: TimeUnit): number | null; parse(value: unknown, format?: TimeUnit): number | null;
/** /**
* Returns the formatted date in the specified `format` for a given `timestamp`. * Returns the formatted date in the specified `format` for a given `timestamp`.
* @param {number} timestamp - the timestamp to format * @param {number} timestamp - the timestamp to format

21
types/element.d.ts vendored
View File

@ -1,6 +1,7 @@
import { AnyObject } from './basic';
import { Point } from './geometric'; import { Point } from './geometric';
export interface Element<T = {}, O = {}> { export interface Element<T = AnyObject, O = AnyObject> {
readonly x: number; readonly x: number;
readonly y: number; readonly y: number;
readonly active: boolean; readonly active: boolean;
@ -8,23 +9,9 @@ export interface Element<T = {}, O = {}> {
tooltipPosition(useFinalPosition?: boolean): Point; tooltipPosition(useFinalPosition?: boolean): Point;
hasValue(): boolean; hasValue(): boolean;
getProps<P extends keyof T>(props: [P], final?: boolean): Pick<T, P>; getProps<P extends (keyof T)[]>(props: P, final?: boolean): Pick<T, P[number]>;
getProps<P extends keyof T, P2 extends keyof T>(props: [P, P2], final?: boolean): Pick<T, P | P2>;
getProps<P extends keyof T, P2 extends keyof T, P3 extends keyof T>(
props: [P, P2, P3],
final?: boolean
): Pick<T, P | P2 | P3>;
getProps<P extends keyof T, P2 extends keyof T, P3 extends keyof T, P4 extends keyof T>(
props: [P, P2, P3, P4],
final?: boolean
): Pick<T, P | P2 | P3 | P4>;
getProps<P extends keyof T, P2 extends keyof T, P3 extends keyof T, P4 extends keyof T, P5 extends keyof T>(
props: [P, P2, P3, P4, P5],
final?: boolean
): Pick<T, P | P2 | P3 | P4 | P5>;
getProps(props: (keyof T)[], final?: boolean): T;
} }
export const Element: { export const Element: {
prototype: Element; prototype: Element;
new <T = {}, O = {}>(): Element<T, O>; new <T = AnyObject, O = AnyObject>(): Element<T, O>;
}; };

View File

@ -1,5 +1,12 @@
export function color(value: CanvasGradient): CanvasGradient; export function color(value: CanvasGradient): CanvasGradient;
export function color(value: CanvasPattern): CanvasPattern; export function color(value: CanvasPattern): CanvasPattern;
export function color(
value:
| string
| { r: number; g: number; b: number; a: number }
| [number, number, number]
| [number, number, number, number]
): ColorModel;
export interface ColorModel { export interface ColorModel {
rgbString(): string; rgbString(): string;
@ -20,13 +27,6 @@ export interface ColorModel {
desaturate(ratio: number): ColorModel; desaturate(ratio: number): ColorModel;
rotate(deg: number): this; rotate(deg: number): this;
} }
export function color(
value:
| string
| { r: number; g: number; b: number; a: number }
| [number, number, number]
| [number, number, number, number]
): ColorModel;
export function getHoverColor(value: CanvasGradient): CanvasGradient; export function getHoverColor(value: CanvasGradient): CanvasGradient;
export function getHoverColor(value: CanvasPattern): CanvasPattern; export function getHoverColor(value: CanvasPattern): CanvasPattern;

View File

@ -12,7 +12,7 @@ export function requestAnimFrame(cb: () => void): void;
* @param {*} thisArg * @param {*} thisArg
* @param {function} [updateFn] * @param {function} [updateFn]
*/ */
export function throttled(fn: (...args: any[]) => void, thisArg: any, updateFn?: (...args: any[]) => any[]): (...args: any[]) => void; export function throttled(fn: (...args: unknown[]) => void, thisArg: unknown, updateFn?: (...args: unknown[]) => unknown[]): (...args: unknown[]) => void;
/** /**
* Debounces calling `fn` for `delay` ms * Debounces calling `fn` for `delay` ms

View File

@ -1,5 +1,5 @@
export function log10(x: number): number; export function log10(x: number): number;
export function isNumber(v: any): boolean; export function isNumber(v: unknown): boolean;
export function almostEquals(x: number, y: number, epsilon: number): boolean; export function almostEquals(x: number, y: number, epsilon: number): boolean;
export function almostWhole(x: number, epsilon: number): number; export function almostWhole(x: number, epsilon: number): number;
export function sign(x: number): number; export function sign(x: number): number;

View File

@ -1156,7 +1156,7 @@ export interface CoreScaleOptions {
afterUpdate(axis: Scale): void; afterUpdate(axis: Scale): void;
} }
export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> extends Element<{}, O>, LayoutItem { export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> extends Element<unknown, O>, LayoutItem {
readonly id: string; readonly id: string;
readonly type: string; readonly type: string;
readonly ctx: CanvasRenderingContext2D; readonly ctx: CanvasRenderingContext2D;
@ -1680,7 +1680,9 @@ export const ArcElement: ChartComponent & {
new (cfg: AnyObject): ArcElement; new (cfg: AnyObject): ArcElement;
}; };
export interface LineProps {} export interface LineProps {
points: Point[]
}
export interface LineOptions extends CommonElementOptions { export interface LineOptions extends CommonElementOptions {
/** /**

4
types/utils.d.ts vendored
View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/ban-types */
// DeepPartial implementation taken from the utility-types NPM package, which is // DeepPartial implementation taken from the utility-types NPM package, which is
// Copyright (c) 2016 Piotr Witek <piotrek.witek@gmail.com> (http://piotrwitek.github.io) // Copyright (c) 2016 Piotr Witek <piotrek.witek@gmail.com> (http://piotrwitek.github.io)
@ -9,10 +10,11 @@ export type DeepPartial<T> = T extends Function
: T extends object : T extends object
? _DeepPartialObject<T> ? _DeepPartialObject<T>
: T | undefined; : T | undefined;
type _DeepPartialArray<T> = Array<DeepPartial<T>> type _DeepPartialArray<T> = Array<DeepPartial<T>>
type _DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> }; type _DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> };
export type DistributiveArray<T> = [T] extends [unknown] ? Array<T> : never export type DistributiveArray<T> = [T] extends [unknown] ? Array<T> : never
// From https://stackoverflow.com/a/50375286 // From https://stackoverflow.com/a/50375286
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never; export type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;