Describe a bug.
html-janitor supports callback pattern in order to customize the sanitizing behavior.
https://github.com/guardian/html-janitor#using-logic
But, it isn't supported as TypeScript definition.
Steps to reproduce:
Example: line 182, src/components/core.ts
this.config.sanitizer = this.config.sanitizer || {
p: true,
b: true,
a: true,
test: (element: any) => true,
} as SanitizerConfig;
$ yarn tsc --noEmit
src/components/core.ts:182:54 - error TS2352: Conversion of type '{ p: true; b: true; a: true; test: (element: any) => boolean; }' to type 'SanitizerConfig' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Property 'test' is incompatible with index signature.
Type '(element: any) => boolean' is not comparable to type 'boolean | { [attr: string]: string | boolean; } | (() => any)'.
Type '(element: any) => boolean' is not comparable to type '() => any'.
182 this.config.sanitizer = this.config.sanitizer || {
~
183 p: true,
~~~~~~~~~~~~~~
...
186 test: (element: any) => true,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
187 } as SanitizerConfig;
Expected behavior:
Prevent TypeScript error even use callback in sanitizer config.
Editor.js version: 2.19.1
Describe a bug.
html-janitor supports callback pattern in order to customize the sanitizing behavior.
https://github.com/guardian/html-janitor#using-logic
But, it isn't supported as TypeScript definition.
Steps to reproduce:
Example: line 182, src/components/core.ts
Expected behavior:
Prevent TypeScript error even use callback in sanitizer config.
Editor.js version: 2.19.1