vue3-core/packages/runtime-core/src/compat/compatConfig.ts

32 lines
731 B
TypeScript
Raw Normal View History

2021-04-07 23:22:56 +08:00
import { extend } from '@vue/shared'
import { DeprecationTypes } from './deprecations'
export type CompatConfig = Partial<
Record<DeprecationTypes, DeprecationConfigItem>
>
export interface DeprecationConfigItem {
warning?: boolean // defaults to true
mode?: 2 | 3 // defaults to 2
}
const globalCompatConfig: CompatConfig = {}
export function configureCompat(config: CompatConfig) {
extend(globalCompatConfig, config)
}
export function getCompatConfig(
key: DeprecationTypes
): DeprecationConfigItem | undefined {
return globalCompatConfig[key]
}
2021-04-08 00:24:45 +08:00
/**
* @internal
*/
export function isCompatEnabled(key: DeprecationTypes): boolean {
const config = getCompatConfig(key)
return !config || config.mode !== 3
}