Skip to content

Application's State type error #653

Open

Description

@Ettapp
function myFunction(app: Application) {
    // ...
}
const app = new Application({ state: { foo: 'bar' }})
myFunction(app)
//         ^^^

In this code, the app constant given to myFunction will be flagged with the following type error:

Argument of type 'Application<{ foo: string; }>' is not assignable to parameter of type 'Application<Record<string, any>>'.
  Types of property '#composedMiddleware' are incompatible.
    Type '((context: Context<{ foo: string; }, { foo: string; }>) => Promise<unknown>) | undefined' is not assignable to type '((context: Context<Record<string, any>, Record<string, any>>) => Promise<unknown>) | undefined'.
      Type '(context: Context<{ foo: string; }, { foo: string; }>) => Promise<unknown>' is not assignable to type '(context: Context<Record<string, any>, Record<string, any>>) => Promise<unknown>'.
        Types of parameters 'context' and 'context' are incompatible.
          Type 'Context<Record<string, any>, Record<string, any>>' is not assignable to type 'Context<{ foo: string; }, { foo: string; }>'.
            Type 'Record<string, any>' is not assignable to type '{ foo: string; }'.

Despite the probable simplicity of the error, I could't find a way to fix it. I'll try a bit longer but if anybody find it, a pull request will save my day x)

Activity

  1. Ettapp commented on May 6, 2024

    @Ettapp
    Author

    One way to make the error vanish:

    const app = new Application<Record<string, unknown>>(...)

    It does not solve the issue but masks the symptom away

  2. Ettapp commented on May 6, 2024

    @Ettapp
    Author

    I closed the issue thinking I found the problem but I was mistaken

  3. reopened this on May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions