Skip to content

Commit

Permalink
Warning: Convert package to TypeScript (#62557)
Browse files Browse the repository at this point in the history
Co-authored-by: jpstevens <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: sirreal <[email protected]>
Co-authored-by: jsnajdr <[email protected]>
Co-authored-by: up1512001 <[email protected]>
  • Loading branch information
6 people authored Jun 14, 2024
1 parent a1c648f commit fe61e1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 5 additions & 0 deletions packages/warning/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Internal

- Refactor to TypeScript ([#62557](https://github.com/WordPress/gutenberg/pull/62557)).

## 3.0.0 (2024-05-31)

### Breaking Changes
Expand Down Expand Up @@ -147,3 +151,4 @@
## 1.0.0 (2020-02-04)

Initial release.

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*/
import { logged } from './utils';

function isDev() {
function isDev(): boolean {
// eslint-disable-next-line @wordpress/wp-global-usage
return globalThis.SCRIPT_DEBUG === true;
}

/**
* Shows a warning with `message` if environment is not `production`.
*
* @param {string} message Message to show in the warning.
* @param message Message to show in the warning.
*
* @example
* ```js
Expand All @@ -25,7 +25,7 @@ function isDev() {
* }
* ```
*/
export default function warning( message ) {
export default function warning( message: string ): void {
if ( ! isDev() ) {
return;
}
Expand All @@ -46,6 +46,5 @@ export default function warning( message ) {
} catch ( x ) {
// Do nothing.
}

logged.add( message );
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Object map tracking messages which have been logged, for use in ensuring a
* message is only logged once.
*
* @type {Set<string>}
*/
export const logged = new Set();
export const logged: Set< string > = new Set();

0 comments on commit fe61e1d

Please sign in to comment.