Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda