refactor: improve function deprecation module (#19012)
* add removeFunction to deprecation module * clarify deprecate api * throw error * change error msg
This commit is contained in:
parent
a90306876e
commit
d79e6bbffe
3 changed files with 18 additions and 5 deletions
|
@ -34,9 +34,21 @@ const deprecate: ElectronInternal.DeprecationUtil = {
|
|||
}
|
||||
},
|
||||
|
||||
// remove a function with no replacement
|
||||
removeFunction: (fn, removedName) => {
|
||||
if (!fn) { throw Error(`'${removedName} function' is invalid or does not exist.`) }
|
||||
|
||||
// wrap the deprecated function to warn user
|
||||
const warn = warnOnce(`${fn.name} function`)
|
||||
return function (this: any) {
|
||||
warn()
|
||||
fn.apply(this, arguments)
|
||||
}
|
||||
},
|
||||
|
||||
// change the name of a function
|
||||
function: (fn, newName) => {
|
||||
const warn = warnOnce(fn.name, newName)
|
||||
renameFunction: (fn, newName) => {
|
||||
const warn = warnOnce(`${fn.name} function`, `${newName} function`)
|
||||
return function (this: any) {
|
||||
warn()
|
||||
fn.apply(this, arguments)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue