question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Types are not preserved

See original GitHub issue

Reproduction

https://stackblitz.com/edit/github-zrvb8t?file=src/App.vue

Steps to reproduce the bug

Open the reproduction and see the browser view.

Expected behavior

Since product type in useStore is Ref<Product>, I expect it to be:

  • Product when doing const { product } = useStore()
  • Ref<Product> when doing const { product } = storeToRefs(useStore())

Actual behavior

product type is object.

Additional information

The current workaround I found:

const store = useStore();
const { product }: { product: Ref<product>; } = storeToRefs(store) as any;
const {} = store; // actions

I think it doesn’t change anything but I’m not using TypeScript in strict mode.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
posvacommented, May 9, 2022

that’s probably a config issue, some options might be overriding some of the rules set by strict true. You should be able to find some help in the discord chat 👍

0reactions
crouchingHamstercommented, Sep 20, 2022

My current workaround const { product }: ToRefs<Pick<IStoreReturn, 'product'>> = storeToRefs(store);

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type-Preserving CPS Translation of Σ and Π Types is Not Not ...
In this paper, we prove that type-preserving CPS translation for dependently typed languages is not not possible. We develop both call-by-name and call-by-value ......
Read more >
Which MongoDB types are not preserved by ... - Stack Overflow
To preserve type information, mongoexport and mongoimport uses the strict mode representation for certain types. What exactly are the types that ...
Read more >
How to solve the error: Preservation Types not valid
Edit the "Preservation Type" table and add your new preservation type ; Save. The preservation type should match exactly the names in the...
Read more >
Which MongoDB types are not preserved by ... - Google Groups
My collection doesn't use any exotic types (only double, int, date, string, bool, object and array), so I should not experience any corruption....
Read more >
Type Systems - Software Foundations
The preservation theorem is often called subject reduction, because it tells us what happens when the "subject" of the typing relation is reduced....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found