Skip to content

[inversify-express-utils] TS2420 in Controller when implementing interfaces.Controller after updating to 6.4.9 #1669

@martin-wrodarczyk-webcom

Description

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

After updating inversify-express-utils from version 6.4.6 to 6.4.9, I encountered the following TypeScript error when using @controller and implementing interfaces.Controller:

error TS2420: Class 'HomeController' incorrectly implements interface 'Controller'.
  Index signature for type 'string' is missing in type 'HomeController'.

The issue appears when using the HomeController class as follows:

@controller('/')
export default class HomeController implements interfaces.Controller {
    private static readonly PRINT_VERSION = '4.6.2';

    private logger: Logger = Logger.getInstance();

    @httpGet('ping.html')
    public async getPing(@request() req: Request, @response() res: Response): Promise<Response> {
        this.logger.log(LogLevel.INFO, 'Ping-Seite aufgerufen.');
        return res
            .status(200)
            .type('html')
            .send(
                `<html><head></head><body><div><ul><li><label id="appstatus">OK</label></li><li><label id="appversion">${
                    HomeController.PRINT_VERSION
                }</label></li><li><label id="timestamp">${new Date().toLocaleString()}</label></li></ul></div></body></html>`
            );
    }
}

Observations

  1. The issue was not present in version 6.4.6. The same code worked without any compilation errors.
  2. The documentation for inversify-express-utils (step 1) implies that implementing interfaces.Controller in this manner should still work.
  3. Upon reviewing the changes between versions, it seems that Controller in interfaces has undergone modifications since version 6.4.7.

Steps to reproduce

  1. Use the above HomeController class with inversify-express-utils 6.4.9
  2. Build the project

Expected behavior

The HomeController class should implement the interfaces.Controller interface without any TypeScript errors, as it did in version 6.4.6.

Possible solution

No response

Package version

6.1.6

Node.js version

20.15.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Stack trace

No response

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions