Skip to content

Commit c31974a

Browse files
committed
fix(reoff-unified-latex): set the types correctly
1 parent 519dfbf commit c31974a

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/lib/reoff-unified-latex.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ type Processor = UnifiedProcessor<any, any, any, any>
99
* Runs the destination with the new unified-latex tree.
1010
*
1111
*/
12-
function bridge(
13-
destination: Processor,
14-
options?: Options,
15-
): void | Transformer<OoxastRoot, OoxastRoot> {
12+
const bridge: Plugin<[Processor, Options?], OoxastRoot> = function (destination, options) {
1613
return (node, file, next) => {
1714
destination.run(toUnifiedLatex(node, options), file, (error) => {
1815
next(error)
@@ -24,10 +21,7 @@ function bridge(
2421
* Mutate-mode.
2522
* Further transformers run on the unified-latex tree.
2623
*/
27-
function mutate(
28-
options: void | Options | undefined = {},
29-
): ReturnType<Plugin<[Options?] | void[], OoxastRoot, Root>> {
30-
//Transformer<JastRoot, JastRoot> | void {
24+
const mutate: Plugin<[Options | void | undefined], OoxastRoot, Root> = function (options = {}) {
3125
return (node, file) => {
3226
const result = toUnifiedLatex(node, file, options)
3327
return result
@@ -49,7 +43,10 @@ function mutate(
4943
* @param options
5044
* Options passed to `ooxast-util-to-unified-latex`.
5145
*/
52-
const reoffUnifiedLatex = function (destination?: Processor | Options, options?: Options) {
46+
const reoffUnifiedLatex: ThisType<Processor> = function (
47+
destination: Processor | Options,
48+
options?: Options,
49+
) {
5350
let settings: Options | undefined
5451
let processor: Processor | undefined
5552

@@ -64,7 +61,7 @@ const reoffUnifiedLatex = function (destination?: Processor | Options, options?:
6461
settings = Object.assign({}, settings, { document: true })
6562
}
6663

67-
return processor ? bridge(processor, settings) : mutate(settings)
68-
} as Plugin<[Processor, Options?], OoxastRoot> & Plugin<[Options?] | void[], OoxastRoot, Root>
64+
return processor ? bridge.call(this, processor, settings) : mutate.call(this, settings)
65+
}
6966

7067
export default reoffUnifiedLatex

0 commit comments

Comments
 (0)