-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Typings error for an reactive object when a property is an Interface that has a private member #2557
Comments
The problem is located here: The index signature makes TS loose the Plain TS example: This will be one for the TS experts (so not me) workaroundreactive(state) as State |
Update:
This breaks unwrapping. type UnwrappedObject<T> = T & { [P in keyof T]: UnwrapRef<T[P]> } & SymbolExtract<T> |
So this will probably have to stay a caveat that requires typecasting. We have to loose the In this specific scenario it means that the private field is "lost" and the class's type has to be cast manually. |
when you convert an object to But if you check the intellisense you will see the types provide the same method but typescript cannot infer the correct type, this again is caused by the class Person {
private name: string
}
// should have the equivalent type
const person = ()=> {
[Symbol('name')]: string
} As for the new type creation vue needs to unwrap because of this: class PersonOther {
name: Ref<number>
}
const a = reactive(new PersonOther)
a.name // is a string |
Will be fixed in #3791. Duplicate of #2981. May close this one? @HcySunYang |
Duplicate of #2981 |
Version
3.0.2
Reproduction link
https://codesandbox.io/s/focused-ives-64y66?file=/src/useWallet.ts
Steps to reproduce
If you check the Codesandbox example, file
useWallet
hover on the line33
you will see the issue that happens.This doesn't happen on a barebone typescript project (as shown here Typescript Example)
What is expected?
The
person
property to have thePerson
type.What is actually happening?
The
person
property has an "objectfied"Person
type.This happens only when there are private properties to the interface.
The text was updated successfully, but these errors were encountered: