Skip to content

Commit

Permalink
chore: added instructions for type declaration (#738)
Browse files Browse the repository at this point in the history
This was based on #184 (comment)
  • Loading branch information
aprilmintacpineda authored Jul 28, 2023
1 parent 8da04aa commit 36a6c56
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,28 @@ defaultConfig {
}
```

## TypeScript declaration for your .env file

If you want to get autocompletion and typesafety for your .env files. Create a file named `react-native-config.d.ts` in the same directory where you put your type declarations, and add the following contents:

```ts
declare module 'react-native-config' {
export interface NativeConfig {
HOSTNAME?: string;
}

export const Config: NativeConfig
export default Config
}
```

Then when you want to use it, you just write:

```
import Config from 'react-native-config';
console.log(Config.HOSTNAME);
```

## Native Usage

### Android
Expand Down

0 comments on commit 36a6c56

Please sign in to comment.