Skip to content
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

TS2353: Object literal may only specify known properties, and 'multiple' does not exist in type Field #1698

Closed
2 of 4 tasks
falk-stefan opened this issue Oct 6, 2024 · 6 comments
Labels

Comments

@falk-stefan
Copy link

falk-stefan commented Oct 6, 2024

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

As far as I am aware, I did not change anything on my end recently which could have caused this but today, all of a sudden, the TypeScript compiler is compalining about the generated routes.ts file.

Taking a look at an earlier version, I see that there's a difference in how the multer.Multer object gets used/updated:

Working version

        // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
        app.put('/api/user/image',
            authenticateMiddleware([{"bearerAuth":["guide:admin"]}]),
            upload.single('file'),
            ...(fetchMiddlewares<RequestHandler>(UserController)),
            ...(fetchMiddlewares<RequestHandler>(UserController.prototype.uploadUserImage)),

Offended version

        // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-g
        app.put('/api/user/image',                                                                      
            authenticateMiddleware([{"bearerAuth":["guide:admin"]}]),                                   
            upload.fields([{"name":"file","maxCount":1,"multiple":false}]),                             
            ...(fetchMiddlewares<RequestHandler>(UserController)),                                      
            ...(fetchMiddlewares<RequestHandler>(UserController.prototype.uploadUserImage)),            

The latter throws the following TS error:

TS2353: Object literal may only specify known properties, and 'multiple' does not exist in type Field

What I don't get here is that I can't see what exactly caused this issue. All deployments re-generate this file and, so far, there were no complaints from the compiler. Not sure what I changed on my end which is causing the issue all of a sudden.

Possibly related

#1651

@jackey8616 jackey8616 added the bug label Oct 7, 2024
@jackey8616
Copy link
Collaborator

@falk-stefan
v 6.5.0 is fired, you can give it a shot.

@falk-stefan
Copy link
Author

@jackey8616 thank you for the hint!

Unfortunately, I am now getting a bunch of errors relating to annotations:

src/controller/user/user.controller.ts:14:1 - error TS1238: Unable to resolve signature of class decorator when called as an expression.
  The runtime will invoke the decorator with 1 arguments, but the decorator expects 3.

14 @Tags('User')
   ~~~~~~~~~~~~~

  node_modules/typescript/lib/lib.decorators.legacy.d.ts:21:52
    21 declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    An argument for 'propertyKey' was not provided.

src/controller/user/user.controller.ts:14:2 - error TS1270: Decorator function return type 'void | TypedPropertyDescriptor<unknown>' is not assignable to type 'void | typeof UserController'.
  Type 'TypedPropertyDescriptor<unknown>' is not assignable to type 'void | typeof UserController'.

14 @Tags('User')
    ~~~~~~~~~~~~

This is what my tsconfig.json looks like:

{
  "compilerOptions": {
    "target": "es2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "rootDir": "./src",
    "sourceMap": true,
    "outDir": "./dist",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitAny": false,
    "skipLibCheck": true,
    "allowJs": true,
    "checkJs": false,
    "experimentalDecorators": true
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.js"
  ],
  "exclude": [
    "node_modules"
  ]
}

I tried to play arround by setting

"emitDecoratorMetadata": true,
"experimentalDecorators": true

but none of the settings would work.

@jackey8616
Copy link
Collaborator

@falk-stefan
we will track this issue at #1702 .

@falk-stefan
Copy link
Author

@jackey8616 thank you 👍

@jackey8616
Copy link
Collaborator

@falk-stefan
The 6.5.1 is released, can you check it out?
If everything is okay, then we will close this issue soon.

@falk-stefan
Copy link
Author

@jackey8616 I gave it a quick test. Looks good so far. I war able to create a local build. Looks good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants