I am quite new to Typescript and I am having little trouble with a interface implemenation.
The interface I have (from d3.js types) :
export interface AxisScale<Domain> {
(x: Domain): number | undefined;
domain(): Domain[];
range(): number[];
copy(): this;
bandwidth?(): number;
// TODO: Reconsider the below, note that the compiler does not differentiate the overloads w.r.t. optionality
// ticks?(count?: number): Domain[];
// ticks?(count?: AxisTimeInterval): Date[];
// tickFormat?(count?: number, specifier?: string): ((d: number) => string);
// tickFormat?(count?: number | AxisTimeInterval, specifier?: string): ((d: Date) => string);
}
This is how I am trying to implement the interface:
export class Axis implements AxisScale<number> {
domain(): (number)[] {
return [5];
}
range(): number[] {
return [5, 10]
}
copy(): this {
return this;
}
bandwidth?(): number {
return d3.scaleBand().align();
}
side: 't' | 'b' | 'l' | 'r';
color: string = "#000000";
padding: number;
margin: Margin;
}
When I save my file and I get this error:
Type 'Axis' provides no match for the signature '(x: number): number'.
How do I implement the anonymous object((x: Domain): number | undefined;) in my class?