feat(types): add asyncData return types to component instance type#9239
Conversation
asyncData types in TypeScriptasyncData return types to component instance type
danielroe
left a comment
There was a problem hiding this comment.
Looks good to me but I'd love @kevinmarrec's eyes on it too.
|
Thanks for the PR @carbotaniuman @danielroe I didn't find time yet to check everything cause it needs to perfectly know Vue types to see if there's any mistake. Also, I thought Finally, before merge I'd like something that show/prove me everything still work (no types breaking) on medium to big projects with these changes. |
They do slightly different things - |
|
Good point. This would probably be better when Nuxt 3 comes around. |
Codecov Report
@@ Coverage Diff @@
## dev #9239 +/- ##
==========================================
- Coverage 65.10% 64.65% -0.46%
==========================================
Files 94 94
Lines 4098 4215 +117
Branches 1121 1168 +47
==========================================
+ Hits 2668 2725 +57
- Misses 1152 1191 +39
- Partials 278 299 +21
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
Can you please check the follow up at #19526? This seems to cause errors (at least with Vue 2.7, haven't checked 2.6). |


Types of changes
Description
This resolves the closed issues #7884 and nuxt/typescript#48. using a variant of @odanado work here. This allows TypeScript users to use the return value of asyncData directly in their
computedandmethodswithout having to duplicate things again indata.Checklist:
I'm not sure where to add these kind of tests, or even if we have tests on the type definitions themselves.