From 740513cda8cb0d1275234ff08d9328d89433285e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Berre=C3=9Fem?= Date: Wed, 3 Apr 2019 14:13:21 +0200 Subject: [PATCH] :rotating_light: remove module declaration --- types/hummus-recipe/hummus-recipe-tests.ts | 28 ++++---- types/hummus-recipe/index.d.ts | 84 +++++++++------------- 2 files changed, 47 insertions(+), 65 deletions(-) diff --git a/types/hummus-recipe/hummus-recipe-tests.ts b/types/hummus-recipe/hummus-recipe-tests.ts index ce6139260f..7503c86aa8 100644 --- a/types/hummus-recipe/hummus-recipe-tests.ts +++ b/types/hummus-recipe/hummus-recipe-tests.ts @@ -1,21 +1,21 @@ import * as HummusRecipe from 'hummus-recipe'; -// $ExpectType HummusRecipe -const pdf = new HummusRecipe('new', 'test.pdf', { - version: 1.6, - author: 'John Doe', - title: 'Hummus Recipe', - subject: 'A brand new PDF', +// $ExpectType Recipe +const pdf = new HummusRecipe.Recipe("new", "test.pdf", { + version: 1.6, + author: "John Doe", + title: "Hummus Recipe", + subject: "A brand new PDF" }); -// $ExpectType HummusRecipe +// $ExpectType Recipe pdf.createPage(595, 842) - .text('Memento Mori', 100, 100) - .endPage() - .endPDF(); + .text("Memento Mori", 100, 100) + .endPage() + .endPDF(); // $ExpectError -pdf.createPage('A4') - .text('Memento Mori', 100, 100) - .endPage() - .endPDF(); +pdf.createPage("A4") + .text("Memento Mori", 100, 100) + .endPage() + .endPDF(); diff --git a/types/hummus-recipe/index.d.ts b/types/hummus-recipe/index.d.ts index ceb135c6d1..c51427a16c 100644 --- a/types/hummus-recipe/index.d.ts +++ b/types/hummus-recipe/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 -declare namespace HummusRecipe { +export declare namespace Recipe { interface RecipeOptions { version?: number; author?: string; @@ -164,19 +164,15 @@ declare namespace HummusRecipe { } } -declare class HummusRecipe { - constructor( - src: string, - output: string, - options?: HummusRecipe.RecipeOptions - ); +export class Recipe { + constructor(src: string, output: string, options?: Recipe.RecipeOptions); comment( text: string, x: number, y: number, - options?: HummusRecipe.CommentOptions - ): HummusRecipe; + options?: Recipe.CommentOptions + ): Recipe; annot( x: number, @@ -198,92 +194,78 @@ declare class HummusRecipe { | "Ink" | "FileAttachment" | "Sound", - options?: HummusRecipe.AnotOptions - ): HummusRecipe; + options?: Recipe.AnotOptions + ): Recipe; - appendPage(pdfSrc: string, pages: number | number[]): HummusRecipe; + appendPage(pdfSrc: string, pages: number | number[]): Recipe; - encrypt(options: HummusRecipe.EncryptOptions): HummusRecipe; + encrypt(options: Recipe.EncryptOptions): Recipe; - registerFont(fontName: string, fontSrcPath: string): HummusRecipe; + registerFont(fontName: string, fontSrcPath: string): Recipe; image( imgSrc: string, x: number, y: number, - options?: HummusRecipe.ImageOptions - ): HummusRecipe; + options?: Recipe.ImageOptions + ): Recipe; - info(options?: HummusRecipe.InfoOptions): HummusRecipe; + info(options?: Recipe.InfoOptions): Recipe; - custom(key?: string, value?: string): HummusRecipe; + custom(key?: string, value?: string): Recipe; insertPage( afterPageNumber: number, pdfSrc: string, srcPageNumber: number - ): HummusRecipe; + ): Recipe; overlay( pdfSrc: string, x: number, y: number, - options?: HummusRecipe.OverlayOptions - ): HummusRecipe; + options?: Recipe.OverlayOptions + ): Recipe; - createPage(pageWidth: number, pageHeight: number): HummusRecipe; + createPage(pageWidth: number, pageHeight: number): Recipe; - endPage(): HummusRecipe; + endPage(): Recipe; - editPage(pageNumber: number): HummusRecipe; + editPage(pageNumber: number): Recipe; - pageInfo(pageNumber: number): HummusRecipe; + pageInfo(pageNumber: number): Recipe; - split(outputDir: string, prefix: string): HummusRecipe; + split(outputDir: string, prefix: string): Recipe; text( text: string, x: number, y: number, - options?: HummusRecipe.TextOptions - ): HummusRecipe; + options?: Recipe.TextOptions + ): Recipe; - moveTo(x: number, y: number): HummusRecipe; + moveTo(x: number, y: number): Recipe; - lineTo( - x: number, - y: number, - options?: HummusRecipe.LineToOptions - ): HummusRecipe; + lineTo(x: number, y: number, options?: Recipe.LineToOptions): Recipe; - line( - coordinates: number[], - options?: HummusRecipe.LineOptions - ): HummusRecipe; + line(coordinates: number[], options?: Recipe.LineOptions): Recipe; - polygon( - coordinates: number[][], - options?: HummusRecipe.PolygonOptions - ): HummusRecipe; + polygon(coordinates: number[][], options?: Recipe.PolygonOptions): Recipe; circle( x: number, y: number, radius: number, - options?: HummusRecipe.CircleOptions - ): HummusRecipe; + options?: Recipe.CircleOptions + ): Recipe; rectangle( x: number, y: number, width: number, height: number, - options?: HummusRecipe.RectangleOptions - ): HummusRecipe; + options?: Recipe.RectangleOptions + ): Recipe; - endPDF(callback?: () => any): HummusRecipe; -} - -declare module "hummus-recipe" { - export = HummusRecipe; + endPDF(callback?: () => any): Recipe; }