const panzoomDefaults = {
a: 3
};
type PanzoomDefaults = typeof panzoomDefaults;
type PanzoomOptionsStartup = {
bind: Element // bind element on startup
};
type PanzoomOptions = Partial<PanzoomOptionsStartup & PanzoomDefaults>;
export class Panzoom implements PanzoomDefaults { // ERROR SHOWS HERE
constructor(options?: PanzoomOptions) {
// Set options
for (const key in panzoomDefaults)
this[key] = options?.hasOwnProperty(key) ? options[key] : panzoomDefaults[key];
}
}
Class 'Panzoom' incorrectly implements interface '{ a: number; }'.
Property 'a' is missing in type 'Panzoom' but required in type '{ a: number; }'.ts(2420)
I know I can simply put a: number in the class or manually do each property of PanzoomOptions
Is there a better way?