eventbrite-sdk-javascript
eventbrite-sdk-javascript copied to clipboard
RequestInit missing from types.d.ts causing failed Typescript builds
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,
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.
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"
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!
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.