jsondiffpatch
jsondiffpatch copied to clipboard
Typescript: how to get an hold on BaseFormatter
I am trying to get an hold on BaseFormatter, but only something like base is exported (jsondiffpatch.esm.js).
https://stackblitz.com/edit/typescript-sgf4s2
How do I get BaseFormatter imported and get rid of any Typescript errors? Thanks for your help.
Also noticed: In d.ts the provided jsonpatch formatter is missing.
I just figured it out:
import { formatters } from 'jsondiffpatch';
export class CeosPropertyDiffFormatter extends (formatters as any).base.default {
...
}
As of v0.6.0, you should now able to import the base formatter like so:
import BaseFormatter from 'jsondiffpatch/formatters/base';
import type { BaseFormatterContext } from 'jsondiffpatch/formatters/base';
export class CeosPropertyDiffFormatter extends BaseFormatter<BaseFormatterContext> {
// impl
}
Let us know if you have any further issues.