]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore(reactivity): replace console.warn() to warn function (#10394)
authorWick <wick.linxunjie@gmail.com>
Sun, 25 Feb 2024 12:17:30 +0000 (20:17 +0800)
committerGitHub <noreply@github.com>
Sun, 25 Feb 2024 12:17:30 +0000 (20:17 +0800)
packages/reactivity/src/collectionHandlers.ts
packages/reactivity/src/reactive.ts
packages/reactivity/src/ref.ts

index 58e69b1cc628dbc167c95582f9c593fcd953a0d3..2b7785ae7ebc56d26d65efc847d38d99abf2c44b 100644 (file)
@@ -7,6 +7,7 @@ import {
 } from './reactiveEffect'
 import { ReactiveFlags, TrackOpTypes, TriggerOpTypes } from './constants'
 import { capitalize, hasChanged, hasOwn, isMap, toRawType } from '@vue/shared'
+import { warn } from './warning'
 
 type CollectionTypes = IterableCollections | WeakCollections
 
@@ -223,7 +224,7 @@ function createReadonlyMethod(type: TriggerOpTypes): Function {
   return function (this: CollectionTypes, ...args: unknown[]) {
     if (__DEV__) {
       const key = args[0] ? `on key "${args[0]}" ` : ``
-      console.warn(
+      warn(
         `${capitalize(type)} operation ${key}failed: target is readonly.`,
         toRaw(this),
       )
@@ -397,7 +398,7 @@ function checkIdentityKeys(
   const rawKey = toRaw(key)
   if (rawKey !== key && has.call(target, rawKey)) {
     const type = toRawType(target)
-    console.warn(
+    warn(
       `Reactive ${type} contains both the raw and reactive ` +
         `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
         `which can lead to inconsistencies. ` +
index 8b94dd9a47f5c676d29128737238225ad8a43b20..1e0f9365daa4b6b888c439fe6a83cf52a6716700 100644 (file)
@@ -13,6 +13,7 @@ import {
 } from './collectionHandlers'
 import type { RawSymbol, Ref, UnwrapRefSimple } from './ref'
 import { ReactiveFlags } from './constants'
+import { warn } from './warning'
 
 export interface Target {
   [ReactiveFlags.SKIP]?: boolean
@@ -247,7 +248,7 @@ function createReactiveObject(
 ) {
   if (!isObject(target)) {
     if (__DEV__) {
-      console.warn(`value cannot be made reactive: ${String(target)}`)
+      warn(`value cannot be made reactive: ${String(target)}`)
     }
     return target
   }
index 1b9d60ef06b62a2b78c19e7f02b71e203b932c0c..5f40fbb7c286cd2380163f0422275c118091f678 100644 (file)
@@ -25,6 +25,7 @@ import type { ShallowReactiveMarker } from './reactive'
 import { type Dep, createDep } from './dep'
 import { ComputedRefImpl } from './computed'
 import { getDepFromReactive } from './reactiveEffect'
+import { warn } from './warning'
 
 declare const RefSymbol: unique symbol
 export declare const RawSymbol: unique symbol
@@ -345,7 +346,7 @@ export type ToRefs<T = any> = {
  */
 export function toRefs<T extends object>(object: T): ToRefs<T> {
   if (__DEV__ && !isProxy(object)) {
-    console.warn(`toRefs() expects a reactive object but received a plain one.`)
+    warn(`toRefs() expects a reactive object but received a plain one.`)
   }
   const ret: any = isArray(object) ? new Array(object.length) : {}
   for (const key in object) {