diff --git a/types/index.d.ts b/types/index.d.ts index da95b33c..f058d2df 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -9,15 +9,7 @@ declare namespace unified { * * @typeParam P Processor settings. Useful when packaging unified with a preset parser and compiler. */ - interface Processor
{ - /** - * Clone current processor - * - * @returns New unfrozen processor which is configured to function the same as its ancestor. - * But when the descendant processor is configured in the future it does not affect the ancestral processor. - */ - (): Processor
- + interface Processor
extends FrozenProcessor
{ /** * Configure the processor to use a plugin and optionally configure that plugin with options. * @@ -61,6 +53,22 @@ declare namespace unified { * @param processorSettings Settings passed to processor */ use(processorSettings: ProcessorSettings
): Processor
+ } + + /** + * A frozen processor is just like a regular processor, except no additional plugins can be added. + * A frozen processor can be created by calling `.freeze()` on a processor. + * + * @see Processor + */ + interface FrozenProcessor
{ + /** + * Clone current processor + * + * @returns New unfrozen processor which is configured to function the same as its ancestor. + * But when the descendant processor is configured in the future it does not affect the ancestral processor. + */ + (): Processor
/** * Parse text to a syntax tree. @@ -200,7 +208,7 @@ declare namespace unified { * * @returns The processor on which freeze is invoked. */ - freeze(): Processor
+ freeze(): FrozenProcessor
}
/**
diff --git a/types/unified-tests.ts b/types/unified-tests.ts
index 60341b8e..3bbcd371 100644
--- a/types/unified-tests.ts
+++ b/types/unified-tests.ts
@@ -11,7 +11,7 @@ let stringValue: string
/**
* `processor()`
*/
-let processor: Processor = unified()
+const processor: Processor = unified()
const clonedProcessor: Processor = processor()
/**
@@ -321,7 +321,9 @@ unknownValue = processor.data().randomKey
/**
* `processor.freeze`
*/
-processor = processor.freeze()
+const frozenProcessor = processor.freeze()
+// $ExpectError
+frozenProcessor.use(plugin)
/**
* Language specific processors
@@ -333,15 +335,16 @@ interface RemarkSettings {
const remark = unified