refactor: change type from 'any' to 'unknown' in ApiResponse and EventHandler for better type safety
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// Generic API types
|
// Generic API types
|
||||||
export interface ApiResponse<T = any> {
|
export interface ApiResponse<T = unknown> {
|
||||||
data?: T
|
data?: T
|
||||||
message?: string
|
message?: string
|
||||||
error?: string
|
error?: string
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Simple event emitter for cross-component communication
|
* Simple event emitter for cross-component communication
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type EventHandler = (...args: any[]) => void
|
type EventHandler = (...args: unknown[]) => void
|
||||||
|
|
||||||
class EventEmitter {
|
class EventEmitter {
|
||||||
private events: Map<string, EventHandler[]> = new Map()
|
private events: Map<string, EventHandler[]> = new Map()
|
||||||
@@ -24,7 +24,7 @@ class EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(event: string, ...args: any[]): void {
|
emit(event: string, ...args: unknown[]): void {
|
||||||
const handlers = this.events.get(event)
|
const handlers = this.events.get(event)
|
||||||
if (handlers) {
|
if (handlers) {
|
||||||
handlers.forEach(handler => handler(...args))
|
handlers.forEach(handler => handler(...args))
|
||||||
|
|||||||
Reference in New Issue
Block a user