Skip to content

Commit

Permalink
Fix types for parse, stringify without settings
Browse files Browse the repository at this point in the history
Related to unifiedjs/unified#67.

Closes GH-433.
Closes GH-434.

Reviewed-by: Victor Felder <[email protected]>
Reviewed-by: Marouane Fazouane <[email protected]>
Reviewed-by: Titus Wormer <[email protected]>
  • Loading branch information
ChristianMurphy authored and wooorm committed Aug 4, 2019
1 parent 391078f commit 166d2f7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/remark-parse/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,7 +13,7 @@ declare class RemarkParser implements Parser {
}

declare namespace remarkParse {
interface Parse extends Attacher<[Partial<RemarkParseOptions>]> {
interface Parse extends Plugin<[Partial<RemarkParseOptions>?]> {
(options: Partial<RemarkParseOptions>): void
Parser: typeof RemarkParser
}
Expand Down
2 changes: 1 addition & 1 deletion packages/remark-parse/types/test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unified = require('unified')
import * as Unist from 'unist'
import remarkParse = require('remark-parse')

const parseOptions = {
gfm: true,
pedantic: true
}

unified().use(remarkParse)
unified().use(remarkParse, parseOptions)

const badParseOptions = {
Expand Down
4 changes: 2 additions & 2 deletions packages/remark-stringify/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -11,7 +11,7 @@ declare class RemarkCompiler implements Compiler {
}

declare namespace remarkStringify {
interface Stringify extends Attacher<[Partial<RemarkStringifyOptions>]> {
interface Stringify extends Plugin<[Partial<RemarkStringifyOptions>?]> {
Compiler: typeof RemarkCompiler
(this: Processor, options?: Partial<RemarkStringifyOptions>): void
}
Expand Down
3 changes: 2 additions & 1 deletion packages/remark-stringify/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const inferredStringifyOptions = {
incrementListMarker: false
}

unified().use(remarkStringify)
unified().use(remarkStringify, inferredStringifyOptions)

// These cannot be automatically inferred by TypeScript
Expand Down Expand Up @@ -48,4 +49,4 @@ function gap(this: unified.Processor) {
}
}

const plugin: unified.Attacher = gap
const plugin: unified.Plugin = gap

0 comments on commit 166d2f7

Please sign in to comment.