Skip to content

Commit 411596c

Browse files
authored
chore(reactivity): replace console.warn() to warn function (#10394)
1 parent ff130c4 commit 411596c

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

packages/reactivity/src/collectionHandlers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from './reactiveEffect'
88
import { ReactiveFlags, TrackOpTypes, TriggerOpTypes } from './constants'
99
import { capitalize, hasChanged, hasOwn, isMap, toRawType } from '@vue/shared'
10+
import { warn } from './warning'
1011

1112
type CollectionTypes = IterableCollections | WeakCollections
1213

@@ -223,7 +224,7 @@ function createReadonlyMethod(type: TriggerOpTypes): Function {
223224
return function (this: CollectionTypes, ...args: unknown[]) {
224225
if (__DEV__) {
225226
const key = args[0] ? `on key "${args[0]}" ` : ``
226-
console.warn(
227+
warn(
227228
`${capitalize(type)} operation ${key}failed: target is readonly.`,
228229
toRaw(this),
229230
)
@@ -397,7 +398,7 @@ function checkIdentityKeys(
397398
const rawKey = toRaw(key)
398399
if (rawKey !== key && has.call(target, rawKey)) {
399400
const type = toRawType(target)
400-
console.warn(
401+
warn(
401402
`Reactive ${type} contains both the raw and reactive ` +
402403
`versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
403404
`which can lead to inconsistencies. ` +

packages/reactivity/src/reactive.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from './collectionHandlers'
1414
import type { RawSymbol, Ref, UnwrapRefSimple } from './ref'
1515
import { ReactiveFlags } from './constants'
16+
import { warn } from './warning'
1617

1718
export interface Target {
1819
[ReactiveFlags.SKIP]?: boolean
@@ -247,7 +248,7 @@ function createReactiveObject(
247248
) {
248249
if (!isObject(target)) {
249250
if (__DEV__) {
250-
console.warn(`value cannot be made reactive: ${String(target)}`)
251+
warn(`value cannot be made reactive: ${String(target)}`)
251252
}
252253
return target
253254
}

packages/reactivity/src/ref.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type { ShallowReactiveMarker } from './reactive'
2525
import { type Dep, createDep } from './dep'
2626
import { ComputedRefImpl } from './computed'
2727
import { getDepFromReactive } from './reactiveEffect'
28+
import { warn } from './warning'
2829

2930
declare const RefSymbol: unique symbol
3031
export declare const RawSymbol: unique symbol
@@ -345,7 +346,7 @@ export type ToRefs<T = any> = {
345346
*/
346347
export function toRefs<T extends object>(object: T): ToRefs<T> {
347348
if (__DEV__ && !isProxy(object)) {
348-
console.warn(`toRefs() expects a reactive object but received a plain one.`)
349+
warn(`toRefs() expects a reactive object but received a plain one.`)
349350
}
350351
const ret: any = isArray(object) ? new Array(object.length) : {}
351352
for (const key in object) {

0 commit comments

Comments
 (0)