@@ -394,6 +394,7 @@ export class MarkdownExit {
394394 */
395395 use ( plugin : PluginSimple ) : this
396396 use < T = any > ( plugin : PluginWithOptions < T > , options ?: T ) : this
397+ use ( plugin : PluginWithParams , ...params : any [ ] ) : this
397398 use ( plugin : PluginWithParams , ...params : any [ ] ) : this {
398399 plugin . apply ( plugin , [ this , ...params ] )
399400 return this
@@ -495,21 +496,30 @@ export function createMarkdownExit(presetNameOrOptions?: any, options?: any): Ma
495496}
496497
497498// hybrid types callable construct signatures hack
498- type MarkdownExitConstructor = {
499- new ( options ?: MarkdownExitOptions ) : MarkdownExit
500- new ( presetName : PresetName , options ?: MarkdownExitOptions ) : MarkdownExit
501- ( options ?: MarkdownExitOptions ) : MarkdownExit
502- ( presetName : PresetName , options ?: MarkdownExitOptions ) : MarkdownExit
503- } & typeof MarkdownExit
504-
505- function _MarkdownExit ( presetName ?: PresetName | MarkdownExitOptions , options ?: MarkdownExitOptions ) : MarkdownExit {
506- return new MarkdownExit ( presetName as any , options )
499+
500+ /**
501+ * Make class callable without `new` operator.
502+ */
503+ function createCallableClass < T extends new ( ...args : any ) => any > ( Class : T ) {
504+ function callable ( ...args : ConstructorParameters < T > ) : InstanceType < T > {
505+ return new Class ( ...args )
506+ }
507+
508+ // bridge statics
509+ Object . setPrototypeOf ( callable , MarkdownExit )
510+
511+ // share the same instance prototype
512+ ; ( callable as any ) . prototype = MarkdownExit . prototype
513+ ; ( callable as any ) . prototype . constructor = callable
514+
515+ return callable as unknown as T
507516}
508517
509- // bridge statics
510- Object . setPrototypeOf ( _MarkdownExit , MarkdownExit )
511- // share the same instance prototype
512- ; ( _MarkdownExit as any ) . prototype = MarkdownExit . prototype
513- ; ( _MarkdownExit as any ) . prototype . constructor = _MarkdownExit
518+ // type and default const variable name must be the same
519+ // for correct d.ts generation
520+ type MarkdownExitConstructor = InstanceType < typeof MarkdownExit >
521+
522+ // eslint-disable-next-line ts/no-redeclare
523+ const MarkdownExitConstructor = createCallableClass ( MarkdownExit ) as unknown as ( typeof createMarkdownExit & typeof MarkdownExit )
514524
515- export default _MarkdownExit as MarkdownExitConstructor
525+ export default MarkdownExitConstructor
0 commit comments