Skip to content

Commit

Permalink
chore: added devWarning util
Browse files Browse the repository at this point in the history
  • Loading branch information
hextion committed Nov 18, 2024
1 parent 6669e55 commit d9a6a14
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './dom';
export * from './exhaustiveCheck';
export * from './context/PortalContext';
export * from './getComponentBreakpoint';
export * from './warning';
11 changes: 11 additions & 0 deletions packages/shared/src/warning.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable no-console */
let warnings: Set<string> | null;

if (process.env.NODE_ENV === 'development') {
warnings = new Set();
}

export function devWarning(message: string) {
if (!(process.env.NODE_ENV === 'development') || warnings?.has(message)) return;
console.warn(message);
}
9 changes: 9 additions & 0 deletions typings/environment.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare global {
namespace NodeJS {
interface ProcessEnv {
NODE_ENV: 'development' | 'production' | 'test';
}
}
}

export {};

0 comments on commit d9a6a14

Please sign in to comment.