From 166d2f770a8df754b21e1b0a9540d6a671d0e713 Mon Sep 17 00:00:00 2001 From: Christian Murphy Date: Sun, 4 Aug 2019 00:30:47 -0700 Subject: [PATCH] Fix types for parse, stringify without settings Related to unifiedjs/unified#67. Closes GH-433. Closes GH-434. Reviewed-by: Victor Felder Reviewed-by: Marouane Fazouane Reviewed-by: Titus Wormer --- packages/remark-parse/types/index.d.ts | 4 ++-- packages/remark-parse/types/test.ts | 2 +- packages/remark-stringify/types/index.d.ts | 4 ++-- packages/remark-stringify/types/test.ts | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/remark-parse/types/index.d.ts b/packages/remark-parse/types/index.d.ts index c8eff9ff0..9586f76a8 100644 --- a/packages/remark-parse/types/index.d.ts +++ b/packages/remark-parse/types/index.d.ts @@ -1,7 +1,7 @@ // TypeScript Version: 3.0 import {Node, Parent, Position} from 'unist' -import {Parser, Attacher} from 'unified' +import {Parser, Plugin} from 'unified' declare class RemarkParser implements Parser { parse(): Node @@ -13,7 +13,7 @@ declare class RemarkParser implements Parser { } declare namespace remarkParse { - interface Parse extends Attacher<[Partial]> { + interface Parse extends Plugin<[Partial?]> { (options: Partial): void Parser: typeof RemarkParser } diff --git a/packages/remark-parse/types/test.ts b/packages/remark-parse/types/test.ts index 99a6a8315..f600cc9d9 100644 --- a/packages/remark-parse/types/test.ts +++ b/packages/remark-parse/types/test.ts @@ -1,5 +1,4 @@ import unified = require('unified') -import * as Unist from 'unist' import remarkParse = require('remark-parse') const parseOptions = { @@ -7,6 +6,7 @@ const parseOptions = { pedantic: true } +unified().use(remarkParse) unified().use(remarkParse, parseOptions) const badParseOptions = { diff --git a/packages/remark-stringify/types/index.d.ts b/packages/remark-stringify/types/index.d.ts index 1f1fa6891..20bcbb064 100644 --- a/packages/remark-stringify/types/index.d.ts +++ b/packages/remark-stringify/types/index.d.ts @@ -1,6 +1,6 @@ // TypeScript Version: 3.0 -import {Attacher, Compiler, Processor} from 'unified' +import {Compiler, Processor, Plugin} from 'unified' import {Node, Parent} from 'unist' declare class RemarkCompiler implements Compiler { @@ -11,7 +11,7 @@ declare class RemarkCompiler implements Compiler { } declare namespace remarkStringify { - interface Stringify extends Attacher<[Partial]> { + interface Stringify extends Plugin<[Partial?]> { Compiler: typeof RemarkCompiler (this: Processor, options?: Partial): void } diff --git a/packages/remark-stringify/types/test.ts b/packages/remark-stringify/types/test.ts index 4e9befbae..d0d8b1d4f 100644 --- a/packages/remark-stringify/types/test.ts +++ b/packages/remark-stringify/types/test.ts @@ -8,6 +8,7 @@ const inferredStringifyOptions = { incrementListMarker: false } +unified().use(remarkStringify) unified().use(remarkStringify, inferredStringifyOptions) // These cannot be automatically inferred by TypeScript @@ -48,4 +49,4 @@ function gap(this: unified.Processor) { } } -const plugin: unified.Attacher = gap +const plugin: unified.Plugin = gap