Skip to content

Commit

Permalink
Make mw.log a namespace again
Browse files Browse the repository at this point in the history
I changed it in a previous commit to include the `mw.log()` function, but this implementation prevents the `mw.log` object from being extended with additional properties
  • Loading branch information
Adrien LESÉNÉCHAL committed Feb 2, 2024
1 parent 4554a3c commit 278d64d
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions mw/log.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ declare global {
function logError(error: Error, topic?: `error.${string}`): void;
}

/**
* Write a verbose message to the browser's console in debug mode.
*
* This method is mainly intended for verbose logging. It is a no-op in production mode.
* In ResourceLoader debug mode, it will use the browser's console.
*
* See {@link mw.log} for other logging methods.
*
* @param {...Mixed} msg Messages to output to console.
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw-method-log
*/
function log(...msg: any[]): void;

/**
* Collection of methods to help log messages to the console.
*
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.log
*/
const log: {
/**
* Write a verbose message to the browser's console in debug mode.
*
* This method is mainly intended for verbose logging. It is a no-op in production mode.
* In ResourceLoader debug mode, it will use the browser's console.
*
* See {@link mw.log} for other logging methods.
*
* @param {...Mixed} msg Messages to output to console.
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw-method-log
*/
(...msg: any[]): void;

namespace log {
/**
* Create a property on a host object that, when accessed, will log
* a deprecation warning to the console.
Expand All @@ -54,7 +54,7 @@ declare global {
* Tracking is disabled by default, except for global variables on `window`.
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw-method-deprecate
*/
deprecate<T, K extends string & keyof T>(
function deprecate<T, K extends string & keyof T>(
obj: T,
key: K,
val: T[K],
Expand All @@ -72,7 +72,7 @@ declare global {
* @param {...Mixed} msg Messages to output to console
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw-method-error
*/
error(...msg: any[]): void;
function error(...msg: any[]): void;

/**
* Create a function that logs a deprecation warning when called.
Expand Down Expand Up @@ -100,16 +100,16 @@ declare global {
* @returns {Function}
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw-method-makeDeprecated
*/
makeDeprecated(key: string | null, msg: string): () => void;
function makeDeprecated(key: string | null, msg: string): () => void;

/**
* Write a message to the browser console's warning channel.
*
* @param {...Mixed} msg Messages to output to console
* @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.log-method-warn
*/
warn(...msg: any[]): void;
};
function warn(...msg: any[]): void;
}
}
}

Expand Down

0 comments on commit 278d64d

Please sign in to comment.