typestack/routing-controllers

fix: TypeError this.targetType.toLowerCase is not a function

akbar12527 opened this issue · 3 comments

Description

Runtime issue with compiled out source js

Using : swc src -d dist --source-maps --copy-files for compilation

\node_modules\routing-controllers\cjs\metadata\ParamMetadata.js:49
            this.isTargetObject = this.targetType instanceof Function || this.targetType.toLowerCase() === 'object';
                                                                                 
        ^

TypeError: this.targetType.toLowerCase is not a function
    at new ParamMetadata (D:\WorkSpaces\DeveLearn\NextCampus\campus-compute\node_modules\routing-controllers\cjs\metadata\ParamMetadata.js:49:90)
    at D:\WorkSpaces\DeveLearn\NextCampus\campus-compute\node_modules\routing-controllers\cjs\metadata-builder\MetadataBuilder.js:108:31
    at Array.map (<anonymous>)
    at MetadataBuilder.createParams (D:\WorkSpaces\DeveLearn\NextCampus\campus-compute\node_modules\routing-controllers\cjs\metadata-builder\MetadataBuilder.js:108:14)
    at D:\WorkSpaces\DeveLearn\NextCampus\campus-compute\node_modules\routing-controllers\cjs\metadata-builder\MetadataBuilder.js:93:38
    at Array.forEach (<anonymous>)
    at MetadataBuilder.createActions (D:\WorkSpaces\DeveLearn\NextCampus\campus-compute\node_modules\routing-controllers\cjs\metadata-builder\MetadataBuilder.js:90:18)
    at D:\WorkSpaces\DeveLearn\NextCampus\campus-compute\node_modules\routing-controllers\cjs\metadata-builder\MetadataBuilder.js:74:39
    at Array.map (<anonymous>)
    at MetadataBuilder.createControllers (D:\WorkSpaces\DeveLearn\NextCampus\campus-compute\node_modules\routing-controllers\cjs\metadata-builder\MetadataBuilder.js:71:28)

Could you include more details? A minimal reproduction snippet would be appreciated.

I’ve successfully diagnosed the issue. A direct Zod schema was unexpectedly passed as a parameter via the controller’s method handler. Interestingly, the linting process was bypassed when the schema was substituted for the type.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.