-
Notifications
You must be signed in to change notification settings - Fork 147
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
Typescript TS2742 error when upgrading 4.X.X to 5.4.0 #1053
Comments
Hey @AGallouin, how do the package is being imported? which typescript version are you using? Could you check if you have the same issue with 5.3.0? |
Issue closed due inactivity. Please, open again the issue if the error persists and you have more evidences. |
@bigmontz what timing haha - I am looking at this issue right now as I am also facing this error. |
@bigmontz for me I've reproduced the issue on 5.14, 5.13, and 5.3.0 since it's mentioned above. I am using [email protected] in a pnpm workspace. My usage is like so: // neo4j.ts
import neo4j from "neo4j-driver";
const { NEO4J_URI, NEO4J_AUTH_USERNAME, NEO4J_AUTH_PASSWORD } = process.env;
if (!NEO4J_URI || !NEO4J_AUTH_USERNAME || !NEO4J_AUTH_PASSWORD) {
throw Error("Missing Neo4j environment variables");
}
export default neo4j.driver(
NEO4J_URI,
neo4j.auth.basic(NEO4J_AUTH_USERNAME, NEO4J_AUTH_PASSWORD)
);
// index.ts
import neo4j from "./neo4j";
import { Draft, Node, Relationship } from "./types";
export default neo4j;
export async function create<T extends keyof Node>(
label: T,
properties: Draft<Node[T]>
) {
const session = neo4j.session();
const res = await session.run<Node[T]>(
`...Cypher query...`,
{ label, ...properties }
);
return res;
} The declaration of the
|
For anyone in need of an interim solution: it's regrettable, but explicitly installing import "neo4j-driver-core"; |
Can you share your tsconfig file? |
I had configured a project like this, // tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"lib": ["ES6", "es2015"],
"noImplicitAny": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"esModuleInterop": true,
"moduleResolution": "node",
"downlevelIteration": true,
"outDir": "lib",
"declaration": true,
"declarationDir": "types",
"isolatedModules": true,
"types": ["node"]
},
"include": [
"index.ts"
]
} // package.json
{
"name": "github1053",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc -p tsconfig.json"
},
"author": "",
"license": "ISC",
"dependencies": {
"neo4j-driver": "^5.14.0"
},
"devDependencies": {
"@types/node": "^20.8.9",
"typescript": "^5.2.2"
}
} // index.ts
import { RecordShape } from "neo4j-driver";
import neo4j from "./neo4j";
export default neo4j;
export async function create<Shape extends RecordShape = RecordShape>(
label: string,
properties: any
) {
const session = neo4j.session();
const res = await session.run<Shape>(
`...Cypher query...`,
{ label, ...properties }
);
return res;
} // neo4j.ts
import neo4j from "neo4j-driver";
// @ts-ignore
const { NEO4J_URI, NEO4J_AUTH_USERNAME, NEO4J_AUTH_PASSWORD } = process.env;
if (!NEO4J_URI || !NEO4J_AUTH_USERNAME || !NEO4J_AUTH_PASSWORD) {
throw Error("Missing Neo4j environment variables");
}
export default neo4j.driver(
NEO4J_URI,
neo4j.auth.basic(NEO4J_AUTH_USERNAME, NEO4J_AUTH_PASSWORD)
); |
@dylanjt Can you share your tsconfig? |
Hello,
When bumping neo4j-driver package from 4.4.2 to 5.4.0, I'm having issues with the base types of neo4j (Integer, Record, Session etc.).
All my neo4j connections are made using a facade package around neo4j-driver, and exposing basic methods and aliases to the types mentioned above to the rest of the codebase. Everytime typescript needs to infer a return type that includes one of thoses types, I have an error like this one.
The only simple solution i found until now is to add directly the package neo4j-driver-core as a dependency of my package even though the readme explicitly tells me otherwise.
Dependency schema if unclear:
I don't even understand why does this error means exactly, do you have any insights on it ?
The text was updated successfully, but these errors were encountered: