-
Notifications
You must be signed in to change notification settings - Fork 507
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
Using Prisma with TSOA #1704
Comments
Hello there wolffsteinn 👋 Thank you for opening your very first issue in this project. We will try to get back to you as soon as we can.👀 |
Is the declaration included in your tsc config?
|
@WoH sorry, im not sure if these are the stuff that you are looking for? i just selected those that seem to be most likely the ones that we require for this discussion! /Users/annabel/Work/node_modules/typescript/lib/lib.decorators.d.ts
/Users/annabel/Work/node_modules/typescript/lib/lib.decorators.legacy.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/deprecated.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/example.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/parameter.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/methods.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/tags.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/operationid.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/route.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/security.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/extension.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/middlewares.d.ts
/Users/annabel/Work/node_modules/@tsoa/runtime/dist/decorators/response.d.ts this is my tsconfig for now {
"compilerOptions": {
"outDir": "./dist",
"module": "CommonJS",
"target": "es2022",
"baseUrl": "./",
"moduleResolution": "node",
"skipLibCheck": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
"removeComments": true,
"strict": true,
"noImplicitAny": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"sourceMap": true,
"strictPropertyInitialization": false,
"sourceRoot": "/"
},
"include": ["src/**/*", "prisma/generated/core"],
"exclude": ["node_modules", "**/dist/**"]
}
Additional context, the type BigIntType = string;
async getAdminRole(): Promise<admin_roles[] | null> {
try {
const adminRoles = await this.coreDatabaseService.admin_roles.findMany();
const response = adminRoles.map((role) => ({
...role,
id: role.id.toString() as BigIntType,
}));
return response as admin_roles[] | null;
} catch (error) {
console.error(error);
throw error;
}
} |
As the error says, the file where the declaration is is probably not part of your files. |
@WoH ah i think yeah i got nipped this prisma declaration issue in the bud, but facing a new error now which is: Generate routes error.
GenerateMetadataError: Unknown type: BigIntKeyword
At unknown position...
This was caused by '<unknown name>'
at TypeResolver.resolve (/Users/annabel/Work/rapidzpay-tsoa/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:292:90)
at /Users/annabel/Work/rapidzpay-tsoa/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:120:118
at Array.reduce (<anonymous>)
at TypeResolver.resolve (/Users/annabel/Work/rapidzpay-tsoa/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:119:85)
at TypeResolver.resolveTypeReferenceNode (/Users/annabel/Work/rapidzpay-tsoa/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:458:93)
at TypeResolver.resolve (/Users/annabel/Work/rapidzpay-tsoa/node_modules/@tsoa/cli/dist/metadataGeneration/typeResolver.js:293:21)
at MethodGenerator.Generate (/Users/annabel/Work/rapidzpay-tsoa/node_modules/@tsoa/cli/dist/metadataGeneration/methodGenerator.js:62:78)
at /Users/annabel/Work/rapidzpay-tsoa/node_modules/@tsoa/cli/dist/metadataGeneration/controllerGenerator.js:46:41
at Array.map (<anonymous>)
at ControllerGenerator.buildMethods (/Users/annabel/Work/rapidzpay-tsoa/node_modules/@tsoa/cli/dist/metadataGeneration/controllerGenerator.js:46:14) i think now it cant read bigint? |
Rather tsoa does not know how you'll serialize it in JSON |
So how do we define serialize for bigint? |
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
Current Behavior
An error is shown stating that tsoa is unable to reference the type
admin_roles
from prisma clientPossible Solution
allow tsoa's typeresolver to be able to read the prisma types that have been generated in the schema?
Steps to Reproduce
Context (Environment)
Version of the library: 6.5.0
Version of NodeJS: 20.17.0
Detailed Description
Breaking change?
The text was updated successfully, but these errors were encountered: