fix: corregir interfaz BadgeJSONInfoType para que coincida con la estructura real de datos#9
Open
chrisvdev wants to merge 1 commit into
Open
fix: corregir interfaz BadgeJSONInfoType para que coincida con la estructura real de datos#9chrisvdev wants to merge 1 commit into
chrisvdev wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problema
Error de TypeScript al pasar badges a
client.connect():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
BadgeJSONInfoTypeusaba la propiedadname, pero los datos JSON reales y el código usantextSolución
nameatextpara coincidir con la estructura JSON realvaluedestringastring | numberpara mayor flexibilidadBadgeJSONInfoTypeyOptionsObjectpara uso externoPruebas
badges.jsonde MTMImtmi-async-badgesArchivos modificados
src/mtmi.ts- Actualizada definición de la interfazsrc/index.ts- Exportados tipos para uso público