diff --git a/index.js b/index.js deleted file mode 100644 index 4cf2ed45..00000000 --- a/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import { RemoteDebugger, REMOTE_DEBUGGER_PORT } from './lib/remote-debugger'; -import RemoteDebuggerRealDevice from './lib/remote-debugger-real-device'; - - -function createRemoteDebugger (opts, realDevice = false) { - if (realDevice) { - return new RemoteDebuggerRealDevice(opts); - } else { - return new RemoteDebugger(opts); - } -} - -export { - createRemoteDebugger, RemoteDebugger, RemoteDebuggerRealDevice, - REMOTE_DEBUGGER_PORT, -}; diff --git a/index.ts b/index.ts new file mode 100644 index 00000000..4247cd6c --- /dev/null +++ b/index.ts @@ -0,0 +1,16 @@ +import { RemoteDebugger, REMOTE_DEBUGGER_PORT } from './lib/remote-debugger'; +import { RemoteDebuggerRealDevice } from './lib/remote-debugger-real-device'; +import type { RemoteDebuggerRealDeviceOptions, RemoteDebuggerOptions } from './lib/types'; + +export function createRemoteDebugger ( + opts: T extends true ? RemoteDebuggerRealDeviceOptions : RemoteDebuggerOptions, + realDevice: T +): T extends true ? RemoteDebuggerRealDevice : RemoteDebugger { + // @ts-ignore TS does not understand that + return realDevice + ? new RemoteDebuggerRealDevice(opts as RemoteDebuggerRealDeviceOptions) + : new RemoteDebugger(opts); +} + +export { RemoteDebugger, RemoteDebuggerRealDevice, REMOTE_DEBUGGER_PORT }; +export type { RemoteDebuggerRealDeviceOptions, RemoteDebuggerOptions }; diff --git a/package.json b/package.json index c1e6e3db..414cb3dc 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "lib": "lib" }, "files": [ - "index.js", + "index.ts", "lib", "build", "scripts", diff --git a/tsconfig.json b/tsconfig.json index 33d83ef4..678d20ad 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,7 @@ "checkJs": true }, "include": [ - "index.js", + "index.ts", "lib" ] }