Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error compiling typescript file that imports earthstar npm package #331

Open
michielbdejong opened this issue May 17, 2024 · 0 comments
Open

Comments

@michielbdejong
Copy link

michielbdejong commented May 17, 2024

Any pointers on how to use the earthstar npm package in a node-typescript project? This is how far I got:

mkdir test
cd test
npm install earthstar
cat << EOF > test.ts
import {
  ExtensionKnownShares,
  ExtensionSyncWeb,
  Replica,
  ReplicaDriverFs,
  Server,
} from "earthstar";
import { createServer } from "http";

const nodeServer = createServer();

const server = new Server([
  new ExtensionKnownShares({
    // known_shares.json contains a JSON array of public share addresses.
    knownSharesPath: "./known_shares.json",
    // Persist share data to disk with ReplicaDriverFs
    onCreateReplica: (shareAddress) => {
      return new Earthstar.Replica({
        driver: new ReplicaDriverFs(shareAddress, "./share_data"),
      });
    },
  }),
  new ExtensionSyncWeb({ server: nodeServer }),
], { server: nodeServer });
EOF
tsc test.ts

Expected: compilation success
Actual:

../node_modules/@deno/sham-weakref/dist/index.d.ts:2:14 - error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.

2     readonly [Symbol.toStringTag]: "WeakRef";
               ~~~~~~~~~~~~~~~~~~~~

../node_modules/@deno/sham-weakref/dist/index.d.ts:2:15 - error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later.

2     readonly [Symbol.toStringTag]: "WeakRef";
                ~~~~~~

../node_modules/@sgwilym/isomorphic-streams/index.d.ts:2:3 - error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type.

2   [Symbol.asyncIterator](): AsyncIterator<R>;
    ~~~~~~~~~~~~~~~~~~~~~~

../node_modules/@sgwilym/isomorphic-streams/index.d.ts:2:4 - error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later.

2   [Symbol.asyncIterator](): AsyncIterator<R>;
     ~~~~~~

../node_modules/@sgwilym/isomorphic-streams/index.d.ts:2:29 - error TS2583: Cannot find name 'AsyncIterator'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
[...]

This is with Version 5.4.5 of tsc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant