Skip to content

Application's State type error #653

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

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