samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.81k stars 94 forks source link

Long output type names cause syntax errors #929

Closed Ziao closed 3 months ago

Ziao commented 3 months ago

Bug Report

Write detailed description in here.

When the generated Output types have long names (such as when inferring the type from a Prisma query), the generated code includes some questionable output.

Code causing the bug


@TypedRoute.Get('cases/:caseId/memos')
    async getMemos(@TypedParam('caseId') caseId: number) {
        return await this.db.memo.findMany({
            where: { case_id: caseId },
            include: {
                topic: true,
            },
        });
    }

Creates the following output:

export namespace getMemos {
    export type Output = topicidnumbernamestringdescriptionstringnullretrieval_queriesstringtopics_to_avoidstringnullcreated_atDateupdated_atDateidnumber...5more...created_atDate[];

    ;

Specifically, the ...5more... part shouldn't be there.

samchon commented 3 months ago

No way to solve this problem in the implicit return type.

Make explicit return type, then this problem be fixed.