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

@uppy/core: migrate to TS #4811

Merged
merged 1 commit into from
Dec 14, 2023
Merged

@uppy/core: migrate to TS #4811

merged 1 commit into from
Dec 14, 2023

Conversation

Murderlon
Copy link
Member

Most noteworthy is that the Uppy class now takes two generics:

 export class Uppy<M extends Meta, B extends Body>

This is so we can correctly type Uppy files with custom metadata and the response body from uploaders.

export interface UppyFile<M extends Meta, B extends Body> {
  // ...
  meta: InternalMetadata & M
  response?: {
    body: B
    status: number
    bytesUploaded?: number
    uploadURL: string
  }
}

In the case of xhr-upload the body is something people have to type themselves because it's their own backend. When working with tus or Transloadit, I imagine we probably need to do something like this:

import type { Response } from '@uppy/transloadit'

type MyMeta = { foo: number }

new Uppy<MyMeta, Response>()

@Murderlon Murderlon self-assigned this Dec 5, 2023
@aduh95 aduh95 changed the base branch from main to 4.x December 5, 2023 11:31
@Murderlon Murderlon marked this pull request as ready for review December 6, 2023 12:50
"rootDir": "./src",
"resolveJsonModule": false,
"noImplicitAny": false,
"skipLibCheck": true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's what causing production TS to ignore untyped dependencies, and because it's not present in tsconfig.json, it reports an error. Maybe we want to re-enable it on prod (and have @ts-expect-error in source files), or we'd want to skip it on the shared options

@aduh95 aduh95 changed the base branch from 4.x to main December 14, 2023 16:29
@aduh95 aduh95 force-pushed the ts-core branch 2 times, most recently from 656c166 to ba05eec Compare December 14, 2023 17:09
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
@aduh95 aduh95 merged commit c48aa82 into main Dec 14, 2023
15 checks passed
@aduh95 aduh95 deleted the ts-core branch December 14, 2023 18:44
this.#uppy = uppy
}

on<K extends keyof _UppyEventMap<M, B>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why three ons?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One is deprecated

@kvz
Copy link
Member

kvz commented Dec 15, 2023

Congrats on landing this team! Milestone! ✨✨💖✨

@arturi
Copy link
Contributor

arturi commented Dec 15, 2023

Massive effort by @Murderlon and @aduh95 (initial TS build setup, utils)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants