import type { ScaleOrdinal, ScaleLinear, ScaleLogarithmic, ScalePower, ScaleRadial, ScaleTime, ScaleQuantile, ScaleQuantize, ScaleThreshold, ScalePoint, ScaleBand, ScaleSymLog } from '@visx/vendor/d3-scale'; import type { StringLike, DefaultOutput, ValueOf } from './Base'; export type DefaultThresholdInput = number | string | Date; /** * Map scale type to D3Scale type * @type `Output`: Output type of all scales except point and band * @type `ThresholdInput`: Input type for threshold scale * @type `DiscreteInput`: Input type for ordinal, point and band scales */ export interface ScaleTypeToD3Scale { linear: ScaleLinear; log: ScaleLogarithmic; pow: ScalePower; sqrt: ScalePower; symlog: ScaleSymLog; radial: ScaleRadial; time: ScaleTime; utc: ScaleTime; quantile: ScaleQuantile; quantize: ScaleQuantize; threshold: ScaleThreshold; ordinal: ScaleOrdinal; point: ScalePoint; band: ScaleBand; } export type PickD3Scale, Output = DefaultOutput, DiscreteInput extends StringLike = StringLike, ThresholdInput extends DefaultThresholdInput = DefaultThresholdInput> = ValueOf, T>>; export type D3Scale = ValueOf>; /** * A catch-all type for all D3 scales. * * Use this instead of `D3Scale` * unless other generic types (`Output`, `DiscreteInput` and `ThresholdInput`) * are also included and passed to `D3Scale`. * Otherwise it may not match some scales (band, point, threshold) correctly and cause TS errors. * * Example error messages: * * "Type 'StringLike' is not assignable to type 'string'" * * "Type 'number' is not assignable to type 'DefaultThresholdInput'" */ export type AnyD3Scale = D3Scale; export type InferD3ScaleOutput = Scale extends D3Scale ? X : DefaultOutput; export type InferD3ScaleDiscreteInput = Scale extends D3Scale ? X : StringLike; export type InferD3ScaleThresholdInput = Scale extends D3Scale ? X : DefaultThresholdInput; /** Get type of scale input from D3 scale */ export type ScaleInput = Parameters[0]; //# sourceMappingURL=Scale.d.ts.map