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

Application's State type error #653

Open
Ettapp opened this issue May 6, 2024 · 2 comments
Open

Application's State type error #653

Ettapp opened this issue May 6, 2024 · 2 comments

Comments

@Ettapp
Copy link

Ettapp commented May 6, 2024

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)

@Ettapp
Copy link
Author

Ettapp commented May 6, 2024

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

@Ettapp Ettapp closed this as completed May 6, 2024
@Ettapp
Copy link
Author

Ettapp commented May 6, 2024

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

@Ettapp Ettapp reopened this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant