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
Could not find a declaration file for module for RN npm package

I created a basic npm package component that allow me to put custom loading images at my Image component, but when I tried to use at my example app the component return undefined and this message appeared: Could not find a declaration file for module 'react-native-default-image'.

After some researchs I find out that it's because the module doesn't provide any typings for TypeScript, but I'm not using TypeScript at all, my component is a .js file. There's some way to pass trought this?

My component file:

import React, { Component } from 'react';
import { Image } from 'react-native';

export default class DefaultImage extends React.Component {
  state = { showDefault: true, error: false };

  render() {
    var image = this.state.showDefault ? this.props.defaultSource : ( this.state.error ? this.props.defaultSource : this.props.source );

    return (
      <Image style={this.props.style} 
             source={{uri: image}} 
             onLoadEnd={() => this.setState({showDefault: false})} 
             onError={() => this.setState({error: true})}
             resizeMode={this.props.resizeMode}/>
    );
  }
}

My index file:

import { DefaultImage } from "./DefaultImage";

export { DefaultImage };

My package.json file:

{
  "name": "react-native-default-image",
  "version": "1.0.3",
  "type": "module",
  "description": "Image component that allow to set up a default image to be shown when the custom image is loading and when the custom image can't be loaded",
  "main": "index.js",
  "directories": {
    "example": "example"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "react-native",
    "image",
    "default"
  ],
  "author": "anti-duhring <mateusvnlima@gmail.com> (http://example.com)",
  "license": "ISC",
  "devDependencies": {
    "@babel/cli": "^7.17.10",
    "@babel/preset-react": "^7.17.12",
    "metro-react-native-babel-preset": "^0.71.0"
  }
}

All my files:

Package folder

about 4 years ago · Juan Pablo Isaza
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