From 634718d6f232f7ab99088cfe8c77c2ed37552efe Mon Sep 17 00:00:00 2001 From: Sarun Intaralawan Date: Thu, 4 Jan 2018 02:47:00 +0700 Subject: [PATCH] fix(@types/croppie): do not export Croppie as default export (#22574) --- types/croppie/croppie-tests.ts | 2 +- types/croppie/index.d.ts | 60 +++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/types/croppie/croppie-tests.ts b/types/croppie/croppie-tests.ts index 26b2449408..581d01435d 100644 --- a/types/croppie/croppie-tests.ts +++ b/types/croppie/croppie-tests.ts @@ -1,4 +1,4 @@ -import Croppie from 'croppie'; +import * as Croppie from 'croppie'; const c = new Croppie(document.getElementById('item'), { boundary: { width: 300, height: 300 }, diff --git a/types/croppie/index.d.ts b/types/croppie/index.d.ts index e2e207db4c..97f53f84c8 100644 --- a/types/croppie/index.d.ts +++ b/types/croppie/index.d.ts @@ -5,8 +5,12 @@ // Sarun Intaralawan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export default class Croppie { - constructor(container: HTMLElement, options?: CroppieOptions); +export as namespace Croppie; + +export = Croppie; + +declare class Croppie { + constructor(container: HTMLElement, options?: Croppie.CroppieOptions); bind(options: { url: string, @@ -16,11 +20,11 @@ export default class Croppie { useCanvas?: boolean, }): Promise; - result(options: ResultOptions & { type: 'base64' | 'canvas' }): Promise; - result(options: ResultOptions & { type: 'html' }): Promise; - result(options: ResultOptions & { type: 'blob' }): Promise; - result(options: ResultOptions & { type: 'rawcanvas' }): Promise; - result(options?: ResultOptions): Promise; + result(options: Croppie.ResultOptions & { type: 'base64' | 'canvas' }): Promise; + result(options: Croppie.ResultOptions & { type: 'html' }): Promise; + result(options: Croppie.ResultOptions & { type: 'blob' }): Promise; + result(options: Croppie.ResultOptions & { type: 'rawcanvas' }): Promise; + result(options?: Croppie.ResultOptions): Promise; rotate(degrees: 90 | 180 | 270 | -90 | -180 | -270): void; @@ -29,28 +33,30 @@ export default class Croppie { destroy(): void; } -export type CropType = 'square' | 'circle'; +declare namespace Croppie { + type CropType = 'square' | 'circle'; -export type Format = 'jpeg' | 'png' | 'webp'; + type Format = 'jpeg' | 'png' | 'webp'; -export type Type = 'canvas' | 'base64' | 'html' | 'blob' | 'rawcanvas'; + type Type = 'canvas' | 'base64' | 'html' | 'blob' | 'rawcanvas'; -export interface ResultOptions { - type?: Type; - size?: 'viewport' | 'original' | { width: number, height: number }; - format?: Format; - quality?: number; - circle?: boolean; -} + interface ResultOptions { + type?: Type; + size?: 'viewport' | 'original' | { width: number, height: number }; + format?: Format; + quality?: number; + circle?: boolean; + } -export interface CroppieOptions { - boundary?: { width: number, height: number }; - customClass?: string; - enableExif?: boolean; - enableOrientation?: boolean; - enableZoom?: boolean; - enforceBoundary?: boolean; - mouseWheelZoom?: boolean; - showZoomer?: boolean; - viewport?: { width: number, height: number, type?: CropType }; + interface CroppieOptions { + boundary?: { width: number, height: number }; + customClass?: string; + enableExif?: boolean; + enableOrientation?: boolean; + enableZoom?: boolean; + enforceBoundary?: boolean; + mouseWheelZoom?: boolean; + showZoomer?: boolean; + viewport?: { width: number, height: number, type?: CropType }; + } }