Unable to use automerge-repo in Deno: Property 'on' missing from 'Repo'
Opened this issue · 0 comments
It seems like automerge-repo currently cannot be used with Deno natively, nor via Deno's npm compatibility layer. When trying to run it natively, Deno complains about all of the imports of .js
files. When trying to import it via npm, the typechecker seems to get hung up on the type of Repo
(specifically its extension of EventEmitter
)
Property 'on' does not exist on type 'Repo'.deno-ts(2339)
Note that the property is definitely there at run-time, but IDEs fail to find it.
Steps to reproduce:
- Make a file called
main.ts
with the following contents:
import {Repo} from "npm:@automerge/automerge-repo@1.0.0-alpha.3";
import {MessageChannelNetworkAdapter} from "npm:@automerge/automerge-repo-network-messagechannel@1.0.0-alpha.3";
const messageChannel = new MessageChannel();
const port = messageChannel.port1;
const repoConfig = {
network: [new MessageChannelNetworkAdapter(port)]
};
const repo = new Repo(repoConfig);
repo.on("document", () => true);
- Open the project in an editor with Deno support (e.g., Visual Studio Code with the Deno extension, or Webstorm with its Deno plugin) and make sure it is enabled for the project. The editor should raise a typerror.

Some additional info which is tangentially related: I ran into this issue when trying to wrap the main classes (DocHandle
, Repo
, etc) with my own classes that have the same interface as the ones being wrapped. This included my classes extending EventEmitter. A problem arose because Deno complained (at run-time) I could not invoke super()
on a superclass twice, the superclass being EventEmitter
. Is it an intended use-case of the eventemitter3 library to extend EventEmitter
?