Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
Overload typescript property from npm package

Problem: Using a 3rd party npm package that has a d.ts file with definitions that are wrong

Looking for: a solution how to overload/introduce the correct types

enter image description here

What is seen on the snapshot is wrong , in fact the function supports objects. How do I change the interface?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you can make the typescript compiler consider the new type with as keyword. for example, if you have an object say

obj= {prop1: 1, prop2: "str", otherProp: ["str"] }

with predefined type

objType = {
 prop1: number; 
 prop2: string;
 otherProp: string[];
}

you can overwrite this type like this

obj= {prop1: 1, prop2: "str"} as newType

type newType = {
  prop1: number; 
  prop2: number;
}

off course, this is not the good approach you should follow, because you lose the importance of using type check, but it is considered a escape hitch in your case

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda