🤖 Merge PR #63772 [markdown-pdf]: Fix the type for to.buffer callback by @priyankark

* Fix markdown-pdf to.buffer type

* Update test

* Prettier Fixes

* Fix tests after prettier formatting changes
This commit is contained in:
Priyankar Kumar
2023-02-16 01:39:51 +05:30
committed by GitHub
parent a9aa86a123
commit b8c1da8734
2 changed files with 36 additions and 10 deletions

View File

@@ -35,8 +35,8 @@ declare namespace MarkdownPDF {
/** A config object that is passed to remarkable, the underlying markdown parser */
remarkable?: any; // FIXME: remarkable config types
}
type PaperFormat = "A3" | "A4" | "A5" | "Legal" | "Letter" | "Tabloid";
type PaperOrientation = "portait" | "landscape";
type PaperFormat = 'A3' | 'A4' | 'A5' | 'Legal' | 'Letter' | 'Tabloid';
type PaperOrientation = 'portait' | 'landscape';
interface OptionsBuilder {
/** Create a readable stream and pipe it to markdown pdf. */
@@ -77,7 +77,7 @@ declare namespace MarkdownPDF {
*/
path(path: string, callback?: () => void): void;
/** Create a concat-stream and pipe output from markdown-pdf to it. The callback function cb will be invoked when the buffer has been created. */
buffer(opts: any, callback?: () => void): void;
buffer(opts: any, callback?: (err: any, buffer: ArrayBuffer) => void): void;
/** Create a concat-stream and pipe output from markdown-pdf to it. The callback function cb will be invoked when the string has been created. */
string(opts: any, callback?: () => void): void;
}

View File

@@ -1,12 +1,38 @@
import mdPdf = require('markdown-pdf');
mdPdf().from('path').to('path', () => { }); // $ExpectType void
mdPdf().from.string('markdown').to('path', () => { }); // $ExpectType void
mdPdf({ paperOrientation: 'landscape', paperFormat: 'A3' }).from('lol').to('lol', () => { }); // $ExpectType void
mdPdf().concat.from.paths(['lol', 'lol'], {}).to('path', () => { }); // $ExpectType void
mdPdf().concat.from.strings(['lol', 'lol'], {}).to('path', () => { }); // $ExpectType void
mdPdf().from('path').to.path('path', () => { }); // $ExpectType void
mdPdf().from('path').to('path'); // $ExpectType void
// $ExpectType void
mdPdf()
.from('path')
.to('path', () => {});
// $ExpectType void
mdPdf()
.from.string('markdown')
.to('path', () => {});
// $ExpectType void
mdPdf({ paperOrientation: 'landscape', paperFormat: 'A3' })
.from('lol')
.to('lol', () => {});
// $ExpectType void
mdPdf()
.concat.from.paths(['lol', 'lol'], {})
.to('path', () => {});
// $ExpectType void
mdPdf()
.concat.from.strings(['lol', 'lol'], {})
.to('path', () => {});
// $ExpectType void
mdPdf()
.from('path')
.to.path('path', () => {});
// $ExpectType void
mdPdf().from('path').to('path');
// $ExpectType void
mdPdf()
.from.string('markdown')
.to.buffer(null, (err, buffer) => {
buffer; // $ExpectType ArrayBuffer
});
// @ts-expect-error
mdPdf({ paperFormat: 'wrongFormat' });