in function reactive, i find useless code
What problem does this feature solve?
i find reactive function declare belows export function reactive(target: object) { // if trying to observe a readonly proxy, return the readonly version. if (target && (target as Target)[ReactiveFlags.IS_READONLY]) { return target } return createReactiveObject( target, false, mutableHandlers, mutableCollectionHandlers ) }
i think if (target && (target as Target)[ReactiveFlags.IS_READONLY]) { return target }
is useless, want to delete
What does the proposed API look like?
export function reactive(target: object) { return createReactiveObject( target, false, mutableHandlers, mutableCollectionHandlers ) }
The use of that piece of code is explained in the comment directly above it.
i think the code above i mentinoned is useless, because in function createReactiveObject will solve the situation that if trying to observe a readonly proxy, return the readonly version, becasuse in createReactiveObject , except readonly() on a reactive object, as long as the target is a proxy, the function createReactiveObject will return the target, so the code is repleat, and when i delete the code above i mentioned, when i run 'npm test', it can pass and has no errors