diff --git a/packages/@uppy/transloadit/src/index.ts b/packages/@uppy/transloadit/src/index.ts index 6d6f60c1b6..2be64a103e 100644 --- a/packages/@uppy/transloadit/src/index.ts +++ b/packages/@uppy/transloadit/src/index.ts @@ -3,7 +3,7 @@ import ErrorWithCause from '@uppy/utils/lib/ErrorWithCause' import { RateLimitedQueue } from '@uppy/utils/lib/RateLimitedQueue' import BasePlugin from '@uppy/core/lib/BasePlugin.js' import type { DefinePluginOpts, PluginOpts } from '@uppy/core/lib/BasePlugin.js' -import Tus, { type TusDetailedError } from '@uppy/tus' +import Tus, { type TusDetailedError, type TusOpts } from '@uppy/tus' import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile' import type { Uppy } from '@uppy/core' import Assembly from './Assembly.ts' @@ -219,7 +219,7 @@ declare module '@uppy/utils/lib/UppyFile' { // eslint-disable-next-line no-shadow, @typescript-eslint/no-unused-vars export interface UppyFile { transloadit?: { assembly: string } - tus?: { uploadUrl?: string | null } + tus?: TusOpts } } @@ -936,7 +936,6 @@ export default class Transloadit< this.uppy.on('upload-success', this.#onFileUploadURLAvailable) } else { // we don't need it here. - // @ts-expect-error `endpoint` is required but we first have to fetch // the regional endpoint from the Transloadit API before we can set it. this.uppy.use(Tus, { // Disable tus-js-client fingerprinting, otherwise uploading the same file at different times diff --git a/packages/@uppy/tus/src/index.ts b/packages/@uppy/tus/src/index.ts index 74d9946aa9..81ebd2eb97 100644 --- a/packages/@uppy/tus/src/index.ts +++ b/packages/@uppy/tus/src/index.ts @@ -24,14 +24,6 @@ import getFingerprint from './getFingerprint.ts' // @ts-ignore We don't want TS to generate types for the package.json import packageJson from '../package.json' -declare module '@uppy/utils/lib/UppyFile' { - // eslint-disable-next-line no-shadow, @typescript-eslint/no-unused-vars - export interface UppyFile { - // TODO: figure out what else is in this type - tus?: { uploadUrl?: string | null } - } -} - type RestTusUploadOptions = Omit< tus.UploadOptions, 'onShouldRetry' | 'onBeforeRequest' | 'headers' @@ -42,7 +34,7 @@ export type TusDetailedError = tus.DetailedError export interface TusOpts extends PluginOpts, RestTusUploadOptions { - endpoint: string + endpoint?: string headers?: | Record | ((file: UppyFile) => Record) @@ -102,6 +94,13 @@ type Opts = DefinePluginOpts< keyof typeof defaultOptions > +declare module '@uppy/utils/lib/UppyFile' { + // eslint-disable-next-line no-shadow, @typescript-eslint/no-unused-vars + export interface UppyFile { + tus?: TusOpts + } +} + /** * Tus resumable file uploader */