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

Typescript exported enum is undefined

$
0
0

I'm writing some typescript type definitions for an existing react native module.

What I've done so far:

  1. added path to my index.d.ts file in the react native module's package.json:
{"name": "react-native-my-module",// ..."main": "index.js","types": "typings/index.d.ts"}
  1. 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?


Viewing all articles
Browse latest Browse all 6314

Trending Articles



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