Browse Source

@uppy/core: improve `UIPluginOptions` types (#4946)

Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
Merlijn Vos 1 năm trước cách đây
mục cha
commit
59ce5a37bc

+ 0 - 1
packages/@uppy/audio/src/Audio.tsx

@@ -14,7 +14,6 @@ import locale from './locale.ts'
 import packageJson from '../package.json'
 
 interface AudioOptions extends UIPluginOptions {
-  target?: HTMLElement | string
   showAudioSourceDropdown?: boolean
 }
 interface AudioState {

+ 7 - 5
packages/@uppy/core/src/UIPlugin.ts

@@ -32,11 +32,6 @@ function debounce<T extends (...args: any[]) => any>(
   }
 }
 
-export interface UIPluginOptions extends PluginOpts {
-  replaceTargetContent?: boolean
-  direction?: 'ltr' | 'rtl'
-}
-
 /**
  * UIPlugin is the extended version of BasePlugin to incorporate rendering with Preact.
  * Use this for plugins that need a user interface.
@@ -44,6 +39,7 @@ export interface UIPluginOptions extends PluginOpts {
  * For plugins without an user interface, see BasePlugin.
  */
 class UIPlugin<
+  // eslint-disable-next-line no-use-before-define
   Opts extends UIPluginOptions,
   M extends Meta,
   B extends Body,
@@ -204,3 +200,9 @@ export type PluginTarget<M extends Meta, B extends Body> =
   | typeof BasePlugin
   | typeof UIPlugin
   | BasePlugin<any, M, B>
+
+export interface UIPluginOptions extends PluginOpts {
+  target?: PluginTarget<any, any>
+  replaceTargetContent?: boolean
+  direction?: 'ltr' | 'rtl'
+}

+ 1 - 1
packages/@uppy/core/src/Uppy.ts

@@ -1910,7 +1910,7 @@ export class Uppy<M extends Meta, B extends Body> {
    * Passes messages to a function, provided in `opts.logger`.
    * If `opts.logger: Uppy.debugLogger` or `opts.debug: true`, logs to the browser console.
    */
-  log(message: string | Record<string, unknown> | Error, type?: string): void {
+  log(message: string | Record<any, any> | Error, type?: string): void {
     const { logger } = this.opts
     switch (type) {
       case 'error':

+ 0 - 1
packages/@uppy/image-editor/src/ImageEditor.tsx

@@ -37,7 +37,6 @@ declare module '@uppy/core' {
 }
 
 interface Opts extends UIPluginOptions {
-  target?: string | HTMLElement
   quality?: number
   cropperOptions?: Cropper.Options & {
     croppedCanvasOptions?: Cropper.GetCroppedCanvasOptions

+ 0 - 1
packages/@uppy/status-bar/src/StatusBarOptions.ts

@@ -2,7 +2,6 @@ import type { UIPluginOptions } from '@uppy/core/lib/UIPlugin'
 import type StatusBarLocale from './locale.ts'
 
 export interface StatusBarOptions extends UIPluginOptions {
-  target?: HTMLElement | string
   showProgressDetails?: boolean
   hideUploadButton?: boolean
   hideAfterFinish?: boolean