Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS strict mode #5258

Merged
merged 7 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@uppy/audio/src/Audio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class Audio<M extends Meta, B extends Body> extends UIPlugin<
> {
static VERSION = packageJson.version

#recordingLengthTimer: ReturnType<typeof setInterval>
#recordingLengthTimer?: ReturnType<typeof setInterval>

private icon

Expand Down
10 changes: 5 additions & 5 deletions packages/@uppy/audio/src/audio-oscilloscope/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ export default class AudioOscilloscope {

private bufferLength: number

private dataArray: Uint8Array
private dataArray?: Uint8Array

// eslint-disable-next-line no-use-before-define
private onDrawFrame: (oscilloscope: AudioOscilloscope) => void

private streamSource?: MediaStreamAudioSourceNode

private audioContext: BaseAudioContext
private audioContext?: BaseAudioContext

public source: AudioBufferSourceNode
public source?: AudioBufferSourceNode

constructor(
canvas: HTMLCanvasElement,
Expand Down Expand Up @@ -98,7 +98,7 @@ export default class AudioOscilloscope {
const h = this.height

if (analyser) {
analyser.getByteTimeDomainData(dataArray)
analyser.getByteTimeDomainData(dataArray!)
}

ctx.fillRect(0, 0, w, h)
Expand All @@ -112,7 +112,7 @@ export default class AudioOscilloscope {
}

for (let i = 0; i < bufferLength; i++) {
const v = dataArray[i] / 128.0
const v = dataArray![i] / 128.0
const y = v * (h / 2)

if (i === 0) {
Expand Down
18 changes: 9 additions & 9 deletions packages/@uppy/aws-s3/src/HTTPCommunicationQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,37 @@ function removeMetadataFromURL(urlString: string) {
}

export class HTTPCommunicationQueue<M extends Meta, B extends Body> {
#abortMultipartUpload: WrapPromiseFunctionType<
#abortMultipartUpload!: WrapPromiseFunctionType<
AwsS3Multipart<M, B>['abortMultipartUpload']
>

#cache = new WeakMap()

#createMultipartUpload: WrapPromiseFunctionType<
#createMultipartUpload!: WrapPromiseFunctionType<
AwsS3Multipart<M, B>['createMultipartUpload']
>

#fetchSignature: WrapPromiseFunctionType<AwsS3Multipart<M, B>['signPart']>
#fetchSignature!: WrapPromiseFunctionType<AwsS3Multipart<M, B>['signPart']>

#getUploadParameters: WrapPromiseFunctionType<
#getUploadParameters!: WrapPromiseFunctionType<
AwsS3Multipart<M, B>['getUploadParameters']
>

#listParts: WrapPromiseFunctionType<AwsS3Multipart<M, B>['listParts']>
#listParts!: WrapPromiseFunctionType<AwsS3Multipart<M, B>['listParts']>

#previousRetryDelay: number
#previousRetryDelay!: number

#requests

#retryDelays: { values: () => Iterator<number> }
#retryDelays!: { values: () => Iterator<number> }

#sendCompletionRequest: WrapPromiseFunctionType<
#sendCompletionRequest!: WrapPromiseFunctionType<
AwsS3Multipart<M, B>['completeMultipartUpload']
>

#setS3MultipartState

#uploadPartBytes: WrapPromiseFunctionType<uploadPartBytes>
#uploadPartBytes!: WrapPromiseFunctionType<uploadPartBytes>

#getFile

Expand Down
6 changes: 3 additions & 3 deletions packages/@uppy/aws-s3/src/MultipartUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class MultipartUploader<M extends Meta, B extends Body> {

#abortController = new AbortController()

#chunks: Array<Chunk | null>
#chunks: Array<Chunk | null> = []

#chunkState: { uploaded: number; etag?: string; done?: boolean }[]
#chunkState: { uploaded: number; etag?: string; done?: boolean }[] = []

/**
* The (un-chunked) data to upload.
Expand Down Expand Up @@ -131,7 +131,7 @@ class MultipartUploader<M extends Meta, B extends Body> {
if (shouldUseMultipart && fileSize > this.#minPartSize) {
// At least 5MB per request:
let chunkSize = Math.max(
this.options.getChunkSize(this.#data),
this.options.getChunkSize(this.#data) as number, // Math.max can take undefined but TS does not think so
this.#minPartSize,
)
let arraySize = Math.floor(fileSize / chunkSize)
Expand Down
10 changes: 6 additions & 4 deletions packages/@uppy/aws-s3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ type AWSS3MultipartWithoutCompanionMandatorySignPart<
) => MaybePromise<AwsS3UploadParameters>
}
type AWSS3MultipartWithoutCompanionMandatory<M extends Meta, B extends Body> = {
getChunkSize?: (file: UppyFile<M, B>) => number
getChunkSize?: (file: { size: number }) => number
createMultipartUpload: (file: UppyFile<M, B>) => MaybePromise<UploadResult>
listParts: (
file: UppyFile<M, B>,
Expand Down Expand Up @@ -314,7 +314,7 @@ export default class AwsS3Multipart<

#companionCommunicationQueue

#client: RequestClient<M, B>
#client!: RequestClient<M, B>

protected requests: any

Expand Down Expand Up @@ -530,7 +530,7 @@ export default class AwsS3Multipart<
.then(assertServerError)
}

#cachedTemporaryCredentials: MaybePromise<AwsS3STSResponse>
#cachedTemporaryCredentials: MaybePromise<AwsS3STSResponse> | undefined
Murderlon marked this conversation as resolved.
Show resolved Hide resolved

async #getTemporarySecurityCredentials(options?: RequestOptions) {
throwIfAborted(options?.signal)
Expand Down Expand Up @@ -859,7 +859,9 @@ export default class AwsS3Multipart<

log: (...args: Parameters<Uppy<M, B>['log']>) => this.uppy.log(...args),
getChunkSize:
this.opts.getChunkSize ? this.opts.getChunkSize.bind(this) : null,
this.opts.getChunkSize ?
this.opts.getChunkSize.bind(this)
: undefined,

onProgress,
onError,
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/box/src/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class Box<M extends Meta, B extends Body> extends UIPlugin<

provider: Provider<M, B>

view: ProviderViews<M, B>
view!: ProviderViews<M, B>

storage: typeof tokenStorage

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/drop-target/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class DropTarget<
> {
static VERSION = packageJson.version

private removeDragOverClassTimeout: ReturnType<typeof setTimeout>
private removeDragOverClassTimeout: ReturnType<typeof setTimeout> | undefined
Murderlon marked this conversation as resolved.
Show resolved Hide resolved

private nodes?: Array<HTMLElement>

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/dropbox/src/Dropbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class Dropbox<M extends Meta, B extends Body> extends UIPlugin<

provider: Provider<M, B>

view: ProviderViews<M, B>
view!: ProviderViews<M, B>

storage: typeof tokenStorage

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/facebook/src/Facebook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class Facebook<M extends Meta, B extends Body> extends UIPlugin<

provider: Provider<M, B>

view: ProviderViews<M, B>
view!: ProviderViews<M, B>

storage: typeof tokenStorage

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/file-input/src/FileInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class FileInput<M extends Meta, B extends Body> extends UIPlugin<
> {
static VERSION = packageJson.version

input: HTMLFileInputElement | null
input: HTMLFileInputElement | null = null

constructor(uppy: Uppy<M, B>, opts?: FileInputOptions) {
super(uppy, { ...defaultOptions, ...opts })
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/form/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class Form<M extends Meta, B extends Body> extends BasePlugin<
> {
static VERSION = packageJson.version

#form: HTMLFormElement
#form!: HTMLFormElement

/**
* Unfortunately Uppy isn't a state machine in which we can guarantee it's
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/golden-retriever/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class GoldenRetriever<

IndexedDBStore: IndexedDBStore

savedPluginData: Record<string, unknown>
savedPluginData?: Record<string, unknown>

constructor(uppy: Uppy<M, B>, opts?: GoldenRetrieverOptions) {
super(uppy, { ...defaultOptions, ...opts })
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/google-drive/src/GoogleDrive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class GoogleDrive<

provider: Provider<M, B>

view: ProviderViews<M, B>
view!: ProviderViews<M, B>

storage: typeof tokenStorage

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/google-photos/src/GooglePhotos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class GooglePhotos<

provider: Provider<M, B>

view: ProviderViews<M, B>
view!: ProviderViews<M, B>

storage: typeof tokenStorage

Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/image-editor/src/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export default class Editor<M extends Meta, B extends Body> extends Component<
Props<M, B>,
State
> {
imgElement: HTMLImageElement
imgElement!: HTMLImageElement

cropper: Cropper
cropper!: Cropper

constructor(props: Props<M, B>) {
super(props)
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/image-editor/src/ImageEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class ImageEditor<
> extends UIPlugin<InternalImageEditorOpts, M, B, PluginState<M, B>> {
static VERSION = packageJson.version

cropper: Cropper
cropper!: Cropper

constructor(uppy: Uppy<M, B>, opts?: Opts) {
super(uppy, {
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/instagram/src/Instagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class Instagram<M extends Meta, B extends Body> extends UIPlugin<

provider: Provider<M, B>

view: ProviderViews<M, B>
view!: ProviderViews<M, B>

storage: typeof tokenStorage

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/onedrive/src/OneDrive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class OneDrive<M extends Meta, B extends Body> extends UIPlugin<

provider: Provider<M, B>

view: ProviderViews<M, B>
view!: ProviderViews<M, B>

storage: typeof tokenStorage

Expand Down
6 changes: 3 additions & 3 deletions packages/@uppy/provider-views/src/View.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export default class View<

isHandlingScroll: boolean

requestClientId: string
requestClientId?: string

isShiftKeyPressed: boolean
isShiftKeyPressed: boolean = false

lastCheckbox: CompanionFile | undefined

Expand Down Expand Up @@ -136,7 +136,7 @@ export default class View<
},
providerName: this.provider.name,
provider: this.provider.provider,
requestClientId: this.requestClientId,
requestClientId: this.requestClientId!,
},
}

Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/react/src/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export interface DashboardProps<M extends Meta, B extends Body>
class Dashboard<M extends Meta, B extends Body> extends Component<
DashboardProps<M, B>
> {
private container: HTMLElement
private container!: HTMLElement

private plugin: UnknownPlugin<M, B>
private plugin!: UnknownPlugin<M, B>

componentDidMount(): void {
this.installPlugin()
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/react/src/DashboardModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class DashboardModal<M extends Meta, B extends Body> extends Component<
onRequestClose: undefined,
}

private container: HTMLElement
private container!: HTMLElement

private plugin: DashboardPlugin<M, B>
private plugin!: DashboardPlugin<M, B>

componentDidMount(): void {
this.installPlugin()
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/react/src/DragDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ interface DragDropProps<M extends Meta, B extends Body>
class DragDrop<M extends Meta, B extends Body> extends Component<
DragDropProps<M, B>
> {
private container: HTMLElement
private container!: HTMLElement

private plugin: UnknownPlugin<M, B>
private plugin!: UnknownPlugin<M, B>

componentDidMount(): void {
this.installPlugin()
Expand Down
6 changes: 3 additions & 3 deletions packages/@uppy/react/src/FileInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class FileInput<M extends Meta, B extends Body> extends Component<
inputName: 'files[]',
}

private container: HTMLElement
private container!: HTMLElement

private plugin: UnknownPlugin<M, B>
private plugin?: UnknownPlugin<M, B>

componentDidMount(): void {
this.installPlugin()
Expand Down Expand Up @@ -65,7 +65,7 @@ class FileInput<M extends Meta, B extends Body> extends Component<
uninstallPlugin(props = this.props): void {
const { uppy } = props

uppy.removePlugin(this.plugin)
uppy.removePlugin(this.plugin!)
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/react/src/ProgressBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ interface ProgressBarProps<M extends Meta, B extends Body>
class ProgressBar<M extends Meta, B extends Body> extends Component<
ProgressBarProps<M, B>
> {
private container: HTMLElement
private container!: HTMLElement

private plugin: UnknownPlugin<M, B>
private plugin!: UnknownPlugin<M, B>

componentDidMount(): void {
this.installPlugin()
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/react/src/StatusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ interface StatusBarProps<M extends Meta, B extends Body>
class StatusBar<M extends Meta, B extends Body> extends Component<
StatusBarProps<M, B>
> {
private container: HTMLElement
private container!: HTMLElement

private plugin: UnknownPlugin<M, B>
private plugin!: UnknownPlugin<M, B>

componentDidMount(): void {
this.installPlugin()
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/screen-capture/src/RecorderScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type RecorderScreenProps<M extends Meta, B extends Body> = {
class RecorderScreen<M extends Meta, B extends Body> extends Component<
RecorderScreenProps<M, B>
> {
videoElement: HTMLVideoElement | null
videoElement: HTMLVideoElement | null = null

componentWillUnmount(): void {
const { onStop } = this.props
Expand Down
Loading