From 2b7d8a255ece3358b73e3aa8c98a5ccdc406f234 Mon Sep 17 00:00:00 2001 From: ArtworkAD Date: Wed, 31 Jan 2018 21:25:06 +0100 Subject: [PATCH] [qrcode]improve types of qrcode@1.2.0 (#23289) * [qrcode]improve types of qrcode@1.2.0 Add toDataURL with promise as response * [qrcode]improve types of qrcode@1.2.0 - add similar methods for toCanvas - method with short signature comes before method with long signature * [qrcode]improve types of qrcode@1.2.0 - toFile promise - toFileStream promise - toString promise --- types/qrcode/index.d.ts | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/types/qrcode/index.d.ts b/types/qrcode/index.d.ts index cb2ce4a9b7..c04a07c20f 100644 --- a/types/qrcode/index.d.ts +++ b/types/qrcode/index.d.ts @@ -127,65 +127,127 @@ export interface QRCode { */ export function create(text: string | QRCodeSegment[], options: QRCodeOptions): QRCode; +/** + * Draws qr code symbol to canvas. + */ +export function toCanvas(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[]): Promise; /** * Draws qr code symbol to canvas. */ export function toCanvas(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], callback: (error: Error) => void): void; +/** + * Draws qr code symbol to canvas. + */ +export function toCanvas(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], options: QRCodeOptions): Promise; /** * Draws qr code symbol to canvas. */ export function toCanvas(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], options: QRCodeOptions, callback: (error: Error) => void): void; +/** + * Draws qr code symbol to canvas. + */ +export function toCanvas(text: string | QRCodeSegment[]): Promise; /** * Draws qr code symbol to canvas. */ export function toCanvas(text: string | QRCodeSegment[], callback: (error: Error, canvas: HTMLCanvasElement) => void): void; +/** + * Draws qr code symbol to canvas. + */ +export function toCanvas(text: string | QRCodeSegment[], options: QRCodeOptions): Promise; /** * Draws qr code symbol to canvas. */ export function toCanvas(text: string | QRCodeSegment[], options: QRCodeOptions, callback: (error: Error, canvas: HTMLCanvasElement) => void): void; +/** + * Draws qr code symbol to node canvas. + */ +export function toCanvas(canvas: any, text: string | QRCodeSegment[]): Promise; /** * Draws qr code symbol to node canvas. */ export function toCanvas(canvas: any, text: string | QRCodeSegment[], callback: (error: Error) => void): void; +/** + * Draws qr code symbol to node canvas. + */ +export function toCanvas(canvas: any, text: string | QRCodeSegment[], options: QRCodeOptions): Promise; /** * Draws qr code symbol to node canvas. */ export function toCanvas(canvas: any, text: string | QRCodeSegment[], options: QRCodeOptions, callback: (error: Error) => void): void; +/** + * Returns a Data URI containing a representation of the QR Code image. + */ +export function toDataURL(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[]): Promise; /** * Returns a Data URI containing a representation of the QR Code image. */ export function toDataURL(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], callback: (error: Error, url: string) => void): void; +/** + * Returns a Data URI containing a representation of the QR Code image. + */ +export function toDataURL(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], options: QRCodeToDataURLOptions): Promise; /** * Returns a Data URI containing a representation of the QR Code image. */ export function toDataURL(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], options: QRCodeToDataURLOptions, callback: (error: Error, url: string) => void): void; +/** + * Returns a Data URI containing a representation of the QR Code image. + */ +export function toDataURL(text: string | QRCodeSegment[]): Promise; /** * Returns a Data URI containing a representation of the QR Code image. */ export function toDataURL(text: string | QRCodeSegment[], callback: (error: Error, url: string) => void): void; +/** + * Returns a Data URI containing a representation of the QR Code image. + */ +export function toDataURL(text: string | QRCodeSegment[], options: QRCodeToDataURLOptions): Promise; /** * Returns a Data URI containing a representation of the QR Code image. */ export function toDataURL(text: string | QRCodeSegment[], options: QRCodeToDataURLOptions, callback: (error: Error, url: string) => void): void; +/** + * Returns a string representation of the QR Code. + * If choosen output format is svg it will returns a string containing xml code. + */ +export function toString(text: string | QRCodeSegment[]): Promise; /** * Returns a string representation of the QR Code. * If choosen output format is svg it will returns a string containing xml code. */ export function toString(text: string | QRCodeSegment[], callback: (error: Error, string: string) => void): void; +/** + * Returns a string representation of the QR Code. + * If choosen output format is svg it will returns a string containing xml code. + */ +export function toString(text: string | QRCodeSegment[], options: QRCodeToStringOptions): Promise; /** * Returns a string representation of the QR Code. * If choosen output format is svg it will returns a string containing xml code. */ export function toString(text: string | QRCodeSegment[], options: QRCodeToStringOptions, callback: (error: Error, string: string) => void): void; +/** + * Saves QR Code to image file. + * If options.type is not specified, the format will be guessed from file extension. + * Recognized extensions are png, svg, txt. + */ +export function toFile(path: string, text: string | QRCodeSegment[]): Promise; /** * Saves QR Code to image file. * If options.type is not specified, the format will be guessed from file extension. * Recognized extensions are png, svg, txt. */ export function toFile(path: string, text: string | QRCodeSegment[], callback: (error: Error) => void): void; +/** + * Saves QR Code to image file. + * If options.type is not specified, the format will be guessed from file extension. + * Recognized extensions are png, svg, txt. + */ +export function toFile(path: string, text: string | QRCodeSegment[], options: QRCodeToFileOptions): Promise; /** * Saves QR Code to image file. * If options.type is not specified, the format will be guessed from file extension. @@ -193,10 +255,18 @@ export function toFile(path: string, text: string | QRCodeSegment[], callback: ( */ export function toFile(path: string, text: string | QRCodeSegment[], options: QRCodeToFileOptions, callback: (error: Error) => void): void; +/** + * Writes QR Code image to stream. Only works with png format for now. + */ +export function toFileStream(stream: stream.Writable, text: string | QRCodeSegment[]): Promise; /** * Writes QR Code image to stream. Only works with png format for now. */ export function toFileStream(stream: stream.Writable, text: string | QRCodeSegment[], callback: (error: Error) => void): void; +/** + * Writes QR Code image to stream. Only works with png format for now. + */ +export function toFileStream(stream: stream.Writable, text: string | QRCodeSegment[], options: QRCodeOptions): Promise; /** * Writes QR Code image to stream. Only works with png format for now. */