-
Notifications
You must be signed in to change notification settings - Fork 33
WIP: Migrate to typescript #22
base: master
Are you sure you want to change the base?
Conversation
this is awesome! a few notes:
|
also we'll probably need to add some infra for writing tests in ts |
I can't merge declarations since I need access to an unexported type. The only other way is to copy the typings file into a local directory and edit and maintain that, or declare the module casting everything to declare namespace NodeIPC {
class IPC {
// ... rest of namespace
}
// 1. I need access to `RootIPC.IPC`, but `NodeIPC.IPC` is not exported
declare const RootIPC: NodeIPC.IPC & {IPC: new () => NodeIPC.IPC};
declare namespace RootIPC {
// 2. so I have to export `NodeIPC.IPC` here, and in a namespace since
// this is a commonjs module
export type IPC = NodeIPC.IPC;
}
export = RootIPC;
When using the // electron_process_injected_code.js
// import RPCConnection from '@jest-runner/rpc/RPCConnection';
import RPCConnection from '@jest-runner/rpc/src/RPCConnection';
// ...
const rpcConnection = new RPCConnection(JestWorkerRPC);
await rpcConnection.connect();
});
migrating the tests to typescript should be fairly straightforward as well. Adjusting the types and using |
we can cast it to |
9be7a2e
to
22af71a
Compare
Ok, I finally managed to conquer babel and get the For the time being, it will generate correctly the required files, but I set up a test file in the electron directory, and I guess make it the official file once it's been migrated as well. As for the tests, they all pass on my machine, but I can't seem to update the snapshots on the ci server, and those are the only 2 tests failing. |
As per our conversation this PR starts the migration to typescript.
Summary of changes:
The rpc module has been completely typed, but it still only builds the
js
source files. Had to leave it like this or else I'd have to continue typing the other packages.For the types, I used
any
whenever the compiler complained and there wasn't a type already provided, otherwise it should be a one-to-one mapping.The only files I didn't migrate were the ones in the root of the module. Doing so would overwrite the original
js
files. But since they just one-liners that point to the build directory, I don't think it would matter if left alone.I ran into an issue with the
IPC
method in thenode-ipc
package that was being used, but was not exposed in the typings. I used thepatch-package
module to provide an easy patch instead of forking or maintaining one.TS 3.0 also introduced the concept of
references
, which allows building multiple projects. This negated the need for a build script, but it no longer shows progress bars.I'll wait to hear from you before proceeding with the rest of the files.