Using javascript neo4j-driver with Typescript

I have used the neo4j-driver in the past but now want to use it in a project written in Typescript. I had expected that I could just get the type definityions by using @types/neo4j-driver like with so many other libraries. Searching the web I have not found anything helpful or even current, this also does not seem to be documented in the official driver docs ( or at least I can't find it). I am surprised it doesn't seem to have come up as a topic here (apologies if it has and I just can't find it - I have looked).

How/where do I get the types for the javascript neo4j-driver to use in a Typescript project?

The type definitions are distributed with the neo4j-driver package and are not in the DefinitelyTyped repo. You can find the type definitions here and can use them like this:

 import neo4j from "neo4j-driver";
 const driver: neo4j.Driver = neo4j.driver("bolt://localhost");
 const session: neo4j.Session = driver.session();
2 Likes

To reopen this topic:

If you wish you can also check out Drivine - a community TypeScript driver with a sweet-spot level of abstraction.

It is designed to scale to hundreds/thousands of txns per second and:

  • Manages infrastructure concerns, such as obtaining and releasing connections and sessions.
  • Facilitates implementation of repositories, which can be injected into services. Your code adheres to single responsibility principle (SRP).
  • Supports declarative, decorator-driven transactions.
  • Supports streaming.
  • Maps and transforms query results onto typed entities or models. Drivine makes an important distinction with regards to its mapping approach. This will be detailed below.