eventbrite-sdk-javascript icon indicating copy to clipboard operation
eventbrite-sdk-javascript copied to clipboard

RequestInit missing from types.d.ts causing failed Typescript builds

Open deremer opened this issue 6 years ago • 4 comments

On "typescript": "^3.0.3", when importing the library as import eventbrite from 'eventbrite';, then running tsc, an error is thrown:

node_modules/eventbrite/lib/types.d.ts:6:42 - error TS2304: Cannot find name 'RequestInit'.

6     request: (apiPath: string, options?: RequestInit) => Promise<{}>;

Expected Behavior

Should compile in Typescript

Possible Solution

Define type or interface for RequestInit.

I've added export type RequestInit = any; to the top of the types file and it complies now. Obviously any is not preferable.

Your Environment

  • SDK version: 1.0.2
  • Node version: 8.11.1
  • Operating system: Mac Mojave

deremer avatar Nov 02 '18 17:11 deremer

@deremer,

We are currently, getting that type from our compiler options being set to use dom. https://github.com/eventbrite/eventbrite-sdk-javascript/blob/master/tsconfig.json#L3

Beyond that we are looking at the proper way to export this within our package properly.

In the mean time, you may be able to leverage that option to solve this problem.

kwelch-eb avatar Nov 05 '18 15:11 kwelch-eb

I've confirmed that adding "dom" to the "lib" compiler option does fix the compile. Not sure if you want to keep this open or close it. For node implementations, it'd probably be preferred to not require "dom"

deremer avatar Nov 12 '18 19:11 deremer

Agreed, that was my exact thought process. Let's leave this open to until we have a proper solution for node.

Thank you for confirming!

kwelch-eb avatar Nov 12 '18 21:11 kwelch-eb

I have looked into this further and the types for isomorphic-fetch have been deprecated in favor or using lib: ['dom'].

https://github.com/DefinitelyTyped/DefinitelyTyped/commit/4cb5f8c313ec0a2671735cb19a8faf8bfdf435ad

I don't full agree with this, but that appears to be their approach to this matter.

kwelch-eb avatar Jan 03 '19 19:01 kwelch-eb