Giter Club home page Giter Club logo

Comments (14)

Acconut avatar Acconut commented on May 29, 2024 2

We personally do not use TypeScript but there are definition files available in the DefinitelyTyped
repository: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/tus-js-client

from tus-js-client.

Acconut avatar Acconut commented on May 29, 2024 1

@nbonavia The definitions in DefinitelyTyped have been updated.

from tus-js-client.

freiondrej avatar freiondrej commented on May 29, 2024 1

@Acconut I just installed 2.1.1 and it seems to be working perfectly. Thank you very much!

from tus-js-client.

brootle avatar brootle commented on May 29, 2024 1

@Acconut you are absolutely right, adding file !== null check before calling new tus.Upload(...) fixes all TypeScript errors and example from npm now runs as it is without any modifications

from tus-js-client.

KhaledSMQ avatar KhaledSMQ commented on May 29, 2024

Thank you

from tus-js-client.

Acconut avatar Acconut commented on May 29, 2024

You're welcome :)

from tus-js-client.

nbonavia avatar nbonavia commented on May 29, 2024

It's missing the metadata property

from tus-js-client.

Acconut avatar Acconut commented on May 29, 2024

Thanks for letting us know, I opened a pull request to add the missing definitions: DefinitelyTyped/DefinitelyTyped#30384

from tus-js-client.

freiondrej avatar freiondrej commented on May 29, 2024

@Acconut hello, are you planning to update the typings for v2, or should I resort to 1.8 for now?

from tus-js-client.

Acconut avatar Acconut commented on May 29, 2024

@freiondrej I added the definitions directly to tus-js-client in 3774a74. Please install the latest version of tus-js-client directly from github and see if they work before I do a real release.

from tus-js-client.

freiondrej avatar freiondrej commented on May 29, 2024

@Acconut thank you. Unfortunately when trying this, I'm getting Can't resolve 'tus-js-client' (I'm using webpack). It surely can be something on my end. But for now I'll stick to the 1.8.0 version which ran just fine for me.

from tus-js-client.

Acconut avatar Acconut commented on May 29, 2024

Version 2.1.0 has been released with the definition file included. Maybe you want to give it another try. I would recommend using the latest version since the 1.x branch won't receive updates in the future.

from tus-js-client.

brootle avatar brootle commented on May 29, 2024

Can anyone post minimalistic example of using tus-js-client with TypeScript? I am trying to use "tus-js-client": "^2.2.0"

I am getting file from event

const file = e.currentTarget.files && e.currentTarget.files[0]

First I got this error Argument of type 'File | null' is not assignable to parameter of type 'File | Blob | Pick<ReadableStreamDefaultReader, "read">'. In the line below

var upload = new tus.Upload(file, {

to fix it I used

var upload = new tus.Upload(file as File, {

and now I am having Object is possibly 'null'.ts(2531) in

metadata: { filename: file.name, filetype: file.type },

I am new to TypeScript, but looks like something is missing in variable definitions. So if somebody can show me the way of implementing example from https://www.npmjs.com/package/tus-js-client that would be super awesome!

UPDATE
So I made it work if I declare file like this
const file = (e.currentTarget.files as FileList)[0]

Not sure if this a right way to go...

from tus-js-client.

Acconut avatar Acconut commented on May 29, 2024

@brootle You are on the right way. The file variable has the type File | null but tus-js-client does not accept null values in the constructor. So that's not a missing definition on our end.

I would recommend you to add a check before calling tus-js-client to make sure that file is not null and you only pass File instances to tus-js-client.

from tus-js-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.