Pull out property of computed value: TypeScript Error
See original GitHub issueinterface IBook { id: string tittle: string ... }
const model = { currentBook?: Computed<Books, IBook | undefined, IBook>; }
currentBook: computed((state) => state.books.find((book) => book.id === state.id))
const Component => {
currentBook?.id // **TypeScript Error Property 'id' does not exist on type 'Computed '.**
currentBook?.title // **TypeScript Error Property 'title' does not exist on type 'Computed '.**
currentBook?.result?.id // undefined
}
@ts-ignore
const { publisher, synopsis, title, author, pageCount, id, coverImageUrl } = currentBook; // WORKS
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
VueJS 2 + TypeScript: computed value does not detect ...
For this reason, you may need to annotate the return type on methods like render and those in computed. Therefore, try this: computed:...
Read more >Computed properties cannot correctly infer even simple return ...
Yarn will load webpack and attempt to build the project, at which point the typescript compilation will fail on the ErrorReproduction.vue file.
Read more >Documentation - TypeScript 2.9
Number-like properties of an object type are those declared using a numeric literal or computed property name of a numeric literal type.
Read more >3 Anti-Patterns to avoid in Vue.js - Binarcode
What actually happens in this case is that, our computed property get's “re-computed” every time in an infinite loop. We change the discount,...
Read more >TypeScript with Composition API - Vue.js
However, it is usually more straightforward to define props with pure types ... double = computed(() => count.value * 2) // => TS...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@jacekk It works properly, thanks for your time.
@Standupic I can see the property --> https://github.com/Standupic/Book-discovery/blob/main/src/types/books.ts#L8 😉 So just add a check in your
Bookcomponent.