@carbon/react
Version:
React components for the Carbon Design System
32 lines (30 loc) • 1.12 kB
JavaScript
/**
* 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.
*/
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_warning = require("./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]) {
require_warning.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
exports.deprecateFieldOnObject = deprecateFieldOnObject;