Do I need to add someting to my tsconfig to be abl...
# orm-help
w
Do I need to add someting to my tsconfig to be able to use types e.g.
Prisma.XXXCreateInput
. Currently compiler throws this error
1
t
You don’t. As for me, it often happens when prisma generate fails. Check node_modules/.prisma generated appropriately. The reason of error may be incorrect schema.prisma or forgetting to run prisma generate(or prisma migrate dev(or deploy)) after changing your schema.
w
Hmm i’m pretty sure it ran…
Importing base model type (State) works though…
t
So, did you import namespace Prisma as named import, not default import? If you can import Prisma namespace, you should be able to infer type from it. Check .prisma/client and drill down for clarifying Namespace export correctly. If not, your problem may be related to architecture of project. For example, your db, prisma version, directory structures, typescript config, etc.
w
Yea idk whats going on, editor recognises types correctly but ts compiler panics. Might need to add path to it in tsconfig explicitly 🤷‍♂️
Copy code
{
  // see <https://www.typescriptlang.org/tsconfig> to better understand tsconfigs
  "include": ["src", "types"],
Will investigate a bit. Using only model type results in no errors whatsoever (ss3) Thx for suggestions
👍 1
t
As for your problem, it will be rollup build configuration. Check tsc --noEmit has no errors without rollup. If do so, your tsconfig.json correct, but rollup build configuration don’t load it correctly during build process. If I were you, I test rollup typescript plugin configurations are suite and appropriately read tsconfig.json then correct formatted build as target. If it’s not enough check versions of library and add plugins suitable. As I knew it, tsc compiling don’t have compatibility completely with another ts-bundle tools such as esbuild. So, if you have trouble to build and can’t resolve for long time, switching build tool like webpack is one of solution because it is rare to fail to compile if your tsc build succeed without in case that you config path modification.
In addition if you use prisma code in serverside as web server, you may not need rollup because the tool focus publishing library (if you’re wanting to do so
@prisma/client
should set external module but, prisma schema needs shared and I don’t recommend to do so because you need to include prisma/client your library and the api depends schema un-configurable) If you don’t use any framework, tsc is enough to run code (though it don’t much support to optimize code bundling.)
In addition, if you bundle code as library, in your isolated module type import may be needed. https://stackoverflow.com/questions/72004458/issue-with-typescript-exported-namespaces-and-rollup