UNPKG

@carbon/react

Version:

React components for the Carbon Design System

31 lines (29 loc) 996 B
/** * Copyright IBM Corp. 2016, 2026 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import { warning } from "./warning.js"; //#region src/internal/deprecateFieldOnObject.ts /** * Copyright IBM Corp. 2016, 2025 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ const deprecateFieldOnObject = (object, field, Component, message) => { const didWarnAboutDeprecation = {}; Object.defineProperty(object, field, { enumerable: true, get: () => { if (!didWarnAboutDeprecation[field]) { warning(false, message || `The ${field} field has been deprecated on the ${object.displayName} object. Please import and use ${Component.displayName || Component.name || "the field"} directly.`); didWarnAboutDeprecation[field] = true; } return Component; } }); }; //#endregion export { deprecateFieldOnObject };