Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!