I'm using this in a project, and updated to 0.14.0-next.1 to solve an issue I ran into when I updated Typescript. However, a new error occurred -- dmmf/utils.d.ts line 1 (in the published npm package for 0.14.0-next.1) has a line:
/// <reference types="react" />
for no apparent reason, and this prevents nexus from generating. If I manually delete the line out of the .d.ts file, it builds fine. I can't tell where or why this gets generated, but it appears to be a bug.
In my case nexus generation works fine - following examples I'm generating schema in transpileOnly mode (ts-node -T)
But there is an issue with this reference when trying to compile project - that forces me to use skipLibcheck:true
Repro
clone some helloworld from ./examples
$ tsc
node_modules/nexus-prisma/dist/dmmf/utils.d.ts:1:23 - error TS2688: Cannot find type definition file for 'react'.
1 /// <reference types="react" />
~~~~~
{
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"lib": ["esnext"],
"strict": true,
"rootDir": "src",
"outDir": "build",
"esModuleInterop": true
// "skipLibCheck": true
},
"include": ["src"]
}
"dependencies": {
"@nexus/schema": "^0.14.0",
"@prisma/client": "^2.0.0-beta.8",
"graphql": "^14.6.0",
"nexus-prisma": "^0.14.0"
},
"devDependencies": {
"@prisma/cli": "^2.0.0-beta.8",
"typescript": "^3.9.5"
}
This is still present in 0.14.0
I've narrowed it down to Typescript 3.9 -- if the package.json is downgraded to 3.8.3, all else being equal, the issue resolves and the reference no longer exists.
I've further narrowed it down to the dev dependency to @prisma/migrate - it's required in a test suite, but if it's removed from package.json, the invalid reference to react disappears. My guess is migrate will need to have some change so tsc doesn't intuit it needs the reference.
I had it too. Install @types/react and @types/ws solved the problem but seems ugly to me
This is very odd, thanks for reporting.
I had it too. Install @types/react and @types/ws solved the problem but seems ugly to me
How is that ugly? You need the types to be able to use them. The fact that VSCode is able to automatically import some types from @types if just a bonus meant to JS users.
I don't think this is a bug. If anything it might be some regression on the typescript side. Or am I missing something?
@Akxe React types should not be needed to work with this library.
@jasonkuhrt For a project that does not include react...?! I did find it there too! Thought I am not getting any errors... interesting (I do not have @react/types installed)
@Akxe react types for a backend library ? Yes, it鈥檚 ugly. @types/ws doesn鈥檛 bother me since I had it on my prisma1 projects so... But simple is better, if it鈥檚 possible to remove some dependencies (as types definitions) it will be nice.
@Akxe react types for a backend library ? Yes, it鈥檚 ugly. @types/ws doesn鈥檛 bother me since I had it on my prisma1 projects so... But simple is better, if it鈥檚 possible to remove some dependencies (as types definitions) it will be nice.
I misunderstood the bug the way it is now is very strange indeed.
0.15.0-next.2 solves this for me.