diff --git a/src/apis/createElement.ts b/src/apis/createElement.ts index 07ae3254..6e05d9db 100644 --- a/src/apis/createElement.ts +++ b/src/apis/createElement.ts @@ -7,17 +7,19 @@ type CreateElement = Vue['$createElement'] let fallbackCreateElement: CreateElement -export const createElement = (function createElement(...args: any) { +export const createElement = function createElement(...args: any) { const instance = getCurrentInstance()?.proxy if (!instance) { - warn('`createElement()` has been called outside of render function.') + __DEV__ && + warn('`createElement()` has been called outside of render function.') if (!fallbackCreateElement) { - fallbackCreateElement = defineComponentInstance(getVueConstructor()) - .$createElement + fallbackCreateElement = defineComponentInstance( + getVueConstructor() + ).$createElement } return fallbackCreateElement.apply(fallbackCreateElement, args) } return instance.$createElement.apply(instance, args) -} as any) as CreateElement +} as any as CreateElement diff --git a/src/apis/inject.ts b/src/apis/inject.ts index 8247a91c..44183798 100644 --- a/src/apis/inject.ts +++ b/src/apis/inject.ts @@ -54,7 +54,8 @@ export function inject( const vm = getCurrentInstance()?.proxy if (!vm) { - warn(`inject() can only be used inside setup() or functional components.`) + __DEV__ && + warn(`inject() can only be used inside setup() or functional components.`) return } diff --git a/src/mixin.ts b/src/mixin.ts index 8ea9292e..078c846c 100644 --- a/src/mixin.ts +++ b/src/mixin.ts @@ -210,10 +210,11 @@ export function mixin(Vue: VueConstructor) { proxy(ctx, key, { get: () => vm[srcKey], set() { - warn( - `Cannot assign to '${key}' because it is a read-only property`, - vm - ) + __DEV__ && + warn( + `Cannot assign to '${key}' because it is a read-only property`, + vm + ) }, }) }) @@ -237,10 +238,11 @@ export function mixin(Vue: VueConstructor) { return data }, set() { - warn( - `Cannot assign to '${key}' because it is a read-only property`, - vm - ) + __DEV__ && + warn( + `Cannot assign to '${key}' because it is a read-only property`, + vm + ) }, }) }) diff --git a/src/utils/helper.ts b/src/utils/helper.ts index b72ce792..753bc907 100644 --- a/src/utils/helper.ts +++ b/src/utils/helper.ts @@ -34,10 +34,12 @@ export function isComponentInstance(obj: any) { export function createSlotProxy(vm: ComponentInstance, slotName: string) { return (...args: any) => { if (!vm.$scopedSlots[slotName]) { - return warn( - `slots.${slotName}() got called outside of the "render()" scope`, - vm - ) + if (__DEV__) + return warn( + `slots.${slotName}() got called outside of the "render()" scope`, + vm + ) + return } return vm.$scopedSlots[slotName]!.apply(vm, args)