Skip to content

fix: corregir interfaz BadgeJSONInfoType para que coincida con la estructura real de datos#9

Open
chrisvdev wants to merge 1 commit into
ManzDev:mainfrom
chrisvdev:fix/badges_type_error
Open

fix: corregir interfaz BadgeJSONInfoType para que coincida con la estructura real de datos#9
chrisvdev wants to merge 1 commit into
ManzDev:mainfrom
chrisvdev:fix/badges_type_error

Conversation

@chrisvdev
Copy link
Copy Markdown
Contributor

@chrisvdev chrisvdev commented May 6, 2026

Problema

Error de TypeScript al pasar badges a client.connect():

Type 'Badges' is not assignable to type 'BadgeJSONInfoType[]'.
Property 'name' is missing in type 'Badge' but required in type 'BadgeJSONInfoType'.

Este error ocurría tanto al usar los badges JSON incluidos en MTMI como al usar paquetes externos como mtmi-async-badges.

Causa raíz

  1. La interfaz BadgeJSONInfoType usaba la propiedad name, pero los datos JSON reales y el código usan text
  2. La interfaz no se exportaba, impidiendo la verificación de tipos en proyectos que consumen MTMI

Solución

  • Cambiado propiedad name a text para coincidir con la estructura JSON real
  • Cambiado tipo de value de string a string | number para mayor flexibilidad
  • Exportados los tipos BadgeJSONInfoType y OptionsObject para uso externo

Pruebas

  • ✅ El build pasa sin errores
  • ✅ Compatible con badges.json de MTMI
  • ✅ Compatible con el paquete mtmi-async-badges
  • ✅ Tipos correctamente exportados en las definiciones compiladas

Archivos modificados

  • src/mtmi.ts - Actualizada definición de la interfaz
  • src/index.ts - Exportados tipos para uso público

…tructure

- 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.
@chrisvdev chrisvdev changed the title fix: correct BadgeJSONInfoType interface to match actual badge data structure fix: corregir interfaz BadgeJSONInfoType para que coincida con la estructura real de datos May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant