From 8e1e850c3d3bb8afe2f6b0bea3e942ae469578bd Mon Sep 17 00:00:00 2001 From: Christian Villegas Date: Wed, 6 May 2026 23:19:12 +0000 Subject: [PATCH] fix: correct BadgeJSONInfoType interface to match actual badge data structure - Changed 'name' property to 'text' to match the actual JSON structure - Changed 'value' type from 'string' to 'string | number' for flexibility - Exported BadgeJSONInfoType and OptionsObject types for external use This fixes the TypeScript error when passing badges (either from mtmi's JSON files or from mtmi-async-badges package) to the client.connect() method. The error was: Type 'Badges' is not assignable to type 'BadgeJSONInfoType[]'. Property 'name' is missing in type 'Badge' but required in type 'BadgeJSONInfoType'. The issue occurred because: 1. The type definition used 'name' but the actual JSON data and code uses 'text' 2. The type was not exported, preventing proper type checking in consuming projects Tested with both mtmi's badges.json and mtmi-async-badges package. --- src/index.ts | 3 +++ src/mtmi.ts | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 776b1c9..0942b5f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,9 @@ // Cliente principal export { client } from "./mtmi.ts"; +// Opciones y configuración +export type { OptionsObject, BadgeJSONInfoType } from "./mtmi.ts"; + // Tipos del mapa de eventos export type { EventType, EventTypeMap } from "./types.ts"; diff --git a/src/mtmi.ts b/src/mtmi.ts index 8deb0fa..87d54a3 100644 --- a/src/mtmi.ts +++ b/src/mtmi.ts @@ -22,10 +22,10 @@ export interface OptionsObject { } export interface BadgeJSONInfoType { - /** Nombre del badge. */ - name: string, + /** Identificador del badge en formato "nombre/valor" (ej: "subscriber/12"). */ + text: string, /** Valor asociado al badge. */ - value: string, + value: string | number, /** Imagen identificativa del badge. */ image: string, /** Descripción del badge. */