-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
COMP: DXDeveloper Experience related issueDeveloper Experience related issueCOMP: typescriptTYPE: bugSomething isn't workingSomething isn't working
Description
Which component is affected?
Qwik Runtime
Describe the bug
Trying to await a function inside onResolved
in a I get
Type '(appointments: MyCustomType) => Promise' is not assignable to type '(value: MyCustomType) => JSXOutput'.
Type 'Promise' is not assignable to type 'JSXOutput'.ts(2322)
core.d.ts(2280, 5): The expected type comes from property 'onResolved' which is declared here on type 'IntrinsicAttributes & ResourceProps'
But even though typescript complains, the code works on my end. So I guess it's just an easy fix on the ts side.
Reproduction
https://stackblitz.com/edit/github-b7kqvv?file=src%2Froutes%2Findex.tsx
Steps to reproduce
Open stackblitz repro, maybe edit the index.tsx file (add a space anywhere to get the ts highlighter).
System Info
🙅♂️
Additional Information
No response
Metadata
Metadata
Assignees
Labels
COMP: DXDeveloper Experience related issueDeveloper Experience related issueCOMP: typescriptTYPE: bugSomething isn't workingSomething isn't working
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Varixo commentedon Nov 23, 2024
This is probably fixed in v2 :D
maiieul commentedon Nov 26, 2024
Although the type fix is probably an easy fix in v1 too no?
wmertens commentedon Apr 28, 2025
Ok I see - but why use an async function here? The render functions are like inline components and those aren't supposed to be async, because it breaks reactivity tracking.
So not sure we should support this @maiieul @Varixo
maiieul commentedon Apr 28, 2025
Hmmm good point. I intuitively went for async inside onResolved to track some analytics data in our codebase. It does work for this use-case but if it breaks reactivity in certain cases then we need to document not to do that and instead create a component$ that can be passed to the
onResolved
.maiieul commentedon Apr 28, 2025
@wmertens are you sure that the render functions behave like inline components and that it breask reactivity tracking? Shouldn't we have a test breaking in that case?
It seems to me that doing
is different from
If returning
Promise<JSXOutput>
doesn't break reactivity I think it's a more intuitive API than constraining the user into creating a component$ just to handle side effects.