Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to define TypeScript Modules in a React Native Project

$
0
0

I have an assets folder which I will be accessing from various locations in my codebase. I wanted to turn this folder into a module by defining a package.json file. My directory looks like this:

app    |-- assets        |-- index.tsx        |-- package.json        |-- ... other resource files    |-- ... rest of my application files

My package.json file contains:

{"name": "assets","version": "0.0.1"}

The file index.tsx has a single export named AssetMap which contains all the required resources. I want to be able to import this object with:

import AssetMap from "assets";

instead of having to type a relative address in each file. What I want to avoid is something like:

import AssetMap from "../ ..stuff.. /assets";

I am fairly certain that this problem I'm facing is specific to TypeScript, as I was following this tutorial to manage static assets. I have just started learning TypeScript and I was unable to find any resources on this specific issue. Any help is appreciated!


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>