Skip to content

Commit e257a80

Browse files
authored
Resovle 'fetch' in nodejs enivronment using whatwg-fetch polyfill (#27)
- Remove redundant type declarations - Add esModuleinterop in tsconfig.json
1 parent 1bb2249 commit e257a80

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

__tests__/setup/setupEnzyme.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
// tslint:disable-next-line
2+
const { Response, Request, Headers, fetch } = require('whatwg-fetch');
3+
4+
// @ts-ignore
5+
const global = {
6+
Headers,
7+
Request,
8+
Response,
9+
fetch,
10+
};
11+
12+
// import Enzyme from 'enzyme';
13+
// import Adapter from 'enzyme-adapter-react-16';
14+
15+
// Enzyme.configure({ adapter: new Adapter() })
16+
117
import { configure } from 'enzyme';
2-
import * as EnzymeAdapter from 'enzyme-adapter-react-16';
3-
configure({ adapter: new EnzymeAdapter() });
18+
import * as ReactSixteenAdapter from 'enzyme-adapter-react-16';
19+
// tslint:disable:no-any
20+
const adapter = ReactSixteenAdapter as any;
21+
configure({ adapter: new adapter.default() });

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"target": "es5",
55
"jsx": "react",
66
"module": "es6",
7+
"esModuleInterop": true,
78
"moduleResolution": "node",
89
"experimentalDecorators": true,
910
"declaration": false,

types/global.d.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
/** Global definitions for development **/
1+
/* Global definitions for development */
22

33
// for style loader
44
declare module '*.css' {
5+
// tslint:disable-next-line:no-any
56
const styles: any;
67
export = styles;
78
}
8-
9-
// Omit type https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-377567046
10-
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
11-
type PartialPick<T, K extends keyof T> = Partial<T> & Pick<T, K>;

0 commit comments

Comments
 (0)