Repository: neet/masto.js
Pull request #51 (2019-05-25 05:15:32)

Use esModuleInterop


Patch:
diff --git a/examples/create-new-status-with-image.ts b/examples/create-new-status-with-image.ts
index b2ae23a8..475fb26c 100644
--- a/examples/create-new-status-with-image.ts
+++ b/examples/create-new-status-with-image.ts
@@ -1,5 +1,5 @@
 // tslint:disable no-console
-import * as fs from 'fs';
+import fs from 'fs';
 import Masto from '../src';
 
 // For more inromation:
diff --git a/examples/update-profile.ts b/examples/update-profile.ts
index 785fa6cc..8017e752 100644
--- a/examples/update-profile.ts
+++ b/examples/update-profile.ts
@@ -1,5 +1,5 @@
 // tslint:disable no-console
-import * as fs from 'fs';
+import fs from 'fs';
 import Masto from '../src';
 
 // For more information:
diff --git a/src/client/decorators.ts b/src/client/decorators.ts
index 901f4258..38987b22 100644
--- a/src/client/decorators.ts
+++ b/src/client/decorators.ts
@@ -1,4 +1,4 @@
-import * as semver from 'semver';
+import semver from 'semver';
 import { MastoNotFoundError } from '../errors/masto-not-found-error';
 import { Masto } from './masto';
 
diff --git a/src/client/gateway.ts b/src/client/gateway.ts
index f8c6736c..f3a4f012 100644
--- a/src/client/gateway.ts
+++ b/src/client/gateway.ts
@@ -1,9 +1,7 @@
 import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
-// tslint:disable-next-line no-import-side-effect
-import 'isomorphic-form-data';
 import normalizeUrl from 'normalize-url';
-import * as querystring from 'querystring';
-import * as semver from 'semver';
+import querystring from 'querystring';
+import semver from 'semver';
 import { oc } from 'ts-optchain';
 import { MastoNotFoundError } from '../errors/masto-not-found-error';
 import { MastoRateLimitError } from '../errors/masto-rate-limit-error';
@@ -11,6 +9,9 @@ import { MastoUnauthorizedError } from '../errors/masto-unauthorized-error';
 import { MastoEvents } from './masto-events';
 import { isAxiosError } from './utils';
 
+// tslint:disable-next-line no-import-side-effect
+import 'isomorphic-form-data';
+
 export interface GatewayConstructor {
   /** URI of the instance */
   uri: string;
diff --git a/src/client/masto-events.ts b/src/client/masto-events.ts
index 09f65c7a..540f46d7 100644
--- a/src/client/masto-events.ts
+++ b/src/client/masto-events.ts
@@ -1,6 +1,6 @@
 // tslint:disable no-unnecessary-override
-import * as EventEmitter from 'eventemitter3';
-import * as WebSocket from 'isomorphic-ws';
+import EventEmitter from 'eventemitter3';
+import WebSocket from 'isomorphic-ws';
 import { Conversation } from '../entities/conversation';
 import { Notification } from '../entities/notification';
 import { Status } from '../entities/status';
diff --git a/tsconfig.json b/tsconfig.json
index 15daee9e..3476d653 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -17,6 +17,7 @@
     ],
     "allowSyntheticDefaultImports": true,
     "declaration": true,
+    "esModuleInterop": true,
     "experimentalDecorators": true,
     "forceConsistentCasingInFileNames": true,
     "moduleResolution": "node",


Test patch:
diff --git a/src/client/__tests__/gateway.spec.ts b/src/client/__tests__/gateway.spec.ts
index e469226b..e64a7241 100644
--- a/src/client/__tests__/gateway.spec.ts
+++ b/src/client/__tests__/gateway.spec.ts
@@ -1,6 +1,6 @@
 // tslint:disable
 import axios from 'axios';
-import * as FormData from 'form-data';
+import FormData from 'form-data';
 import { Gateway } from '../gateway';
 // @ts-ignore
 import { MastoEvents, connectMock } from '../masto-events';
diff --git a/src/client/__tests__/masto-events.spec.ts b/src/client/__tests__/masto-events.spec.ts
index 0414b96e..9f2ee56f 100644
--- a/src/client/__tests__/masto-events.spec.ts
+++ b/src/client/__tests__/masto-events.spec.ts
@@ -1,5 +1,5 @@
 // tslint:disable
-import * as WebSocket from 'isomorphic-ws';
+import WebSocket from 'isomorphic-ws';
 import { MastoEvents } from '../masto-events';
 
 const onMock = jest.fn();