I'm writing some typescript type definitions for an existing react native module.
What I've done so far:
- added path to my
index.d.ts
file in the react native module'spackage.json
:
{"name": "react-native-my-module",// ..."main": "index.js","types": "typings/index.d.ts"}
- write my type definitions as follow:
import { EventSubscriptionVendor } from 'react-native';declare module "react-native-my-module" { export enum MyValues { ValueOne = 'one', ValueTwo = 'two' } export interface SomeType<T> { code: number, description: string, message: T } // ...}
The problem I have is that when I use this react native module in a react native test project, the type definitions seem to be used in my IDE but at runtime, the code below gives me undefined
for the enum:
import Blabla, { MyValues, SomeType } from "react-native-my-module";// ...console.log('MyValues is =', MyValues); // gives 'MyValues is =, undefined'
Questions:
why is my enum undefined in the test project?
is there any other conf to add to the react-native module or the test project for typescript to work correctly?