putdotio / putio-js

JavaScript SDK for interacting with the put.io API.
MIT License
21 stars 2 forks source link

Add strict:true to tsconfig #9

Closed cenkalti closed 4 years ago

cenkalti commented 4 years ago

I cannot use this library in my application without setting strict:false or skipLibCheck:true in my tsconfig becuase this library contains type errors. I suggest adding this option, then fix all of the errors reported by TypeScript compiler.

cenkalti commented 4 years ago

These are the errors when strict flag is set to true:

src/client.ts:45:10 - error TS2564: Property 'token' has no initializer and is not definitely assigned in the constructor.

45   public token: string
            ~~~~~

src/client.ts:47:10 - error TS2564: Property 'emit' has no initializer and is not definitely assigned in the constructor.

47   public emit: (event: PutioAPIClientEventTypes, ...args: any[]) => void
            ~~~~

src/client.ts:48:10 - error TS2416: Property 'once' in type 'PutioAPIClient' is not assignable to the same property in base type 'Emitter'.
  Type '(event: PutioAPIClientEventTypes, listener: EventListener) => void' is not assignable to type 'EmitterMethod'.
    Types of parameters 'event' and 'type' are incompatible.
      Type 'string' is not assignable to type 'PutioAPIClientEventTypes'.

48   public once: (
            ~~~~

src/client.ts:48:10 - error TS2564: Property 'once' has no initializer and is not definitely assigned in the constructor.

48   public once: (
            ~~~~

src/client.ts:52:10 - error TS2416: Property 'on' in type 'PutioAPIClient' is not assignable to the same property in base type 'Emitter'.
  Type '(event: PutioAPIClientEventTypes, listener: EventListener) => void' is not assignable to type 'EmitterMethod'.
    Types of parameters 'event' and 'type' are incompatible.
      Type 'string' is not assignable to type 'PutioAPIClientEventTypes'.

52   public on: (event: PutioAPIClientEventTypes, listener: EventListener) => void
            ~~

src/client.ts:52:10 - error TS2564: Property 'on' has no initializer and is not definitely assigned in the constructor.

52   public on: (event: PutioAPIClientEventTypes, listener: EventListener) => void
            ~~

src/client.ts:53:10 - error TS2416: Property 'off' in type 'PutioAPIClient' is not assignable to the same property in base type 'Emitter'.
  Type '(event: PutioAPIClientEventTypes, listener: EventListener) => void' is not assignable to type 'EmitterMethod'.
    Types of parameters 'event' and 'type' are incompatible.
      Type 'string' is not assignable to type 'PutioAPIClientEventTypes'.

53   public off: (event: PutioAPIClientEventTypes, listener: EventListener) => void
            ~~~

src/client.ts:53:10 - error TS2564: Property 'off' has no initializer and is not definitely assigned in the constructor.

53   public off: (event: PutioAPIClientEventTypes, listener: EventListener) => void
            ~~~

src/client.ts:57:10 - error TS2564: Property 'Account' has no initializer and is not definitely assigned in the constructor.

57   public Account: Account
            ~~~~~~~

src/resources/Auth.ts:49:41 - error TS2532: Object is possibly 'undefined'.

49       `/oauth2/authorizations/clients/${app.client_id}?client_secret=${app.client_secret}`,
                                           ~~~

src/resources/Auth.ts:49:72 - error TS2532: Object is possibly 'undefined'.

49       `/oauth2/authorizations/clients/${app.client_id}?client_secret=${app.client_secret}`,
                                                                          ~~~

src/resources/Payment/Payment.ts:67:21 - error TS7006: Parameter 'args' implicitly has an 'any' type.

67   public ChangePlan(args) {
                       ~~~~

src/resources/Payment/Payment.ts:113:28 - error TS7006: Parameter 'data' implicitly has an 'any' type.

113   public AddWaitingPayment(data) {
                               ~~~~

src/utils/index.ts:8:44 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(o: {}): string[]', gave the following error.
    Argument of type 'object | null' is not assignable to parameter of type '{}'.
      Type 'null' is not assignable to type '{}'.
  Overload 2 of 2, '(o: object): string[]', gave the following error.
    Argument of type 'object | null' is not assignable to parameter of type 'object'.
      Type 'null' is not assignable to type 'object'.

8   typeof input === 'object' && Object.keys(input).includes('error_type')
                                             ~~~~~

Found 14 errors.
altaywtf commented 4 years ago

👍