* Altered typing of NativeModulesStatic to enable NativeModule modules of type any and typed native modules at the same time.
 * Added test case for typed and untyped native modules.
This commit is contained in:
Sahin Vardar
2017-08-29 20:18:46 +02:00
parent 67155af311
commit be58e6ad16
2 changed files with 21 additions and 2 deletions

View File

@@ -9126,9 +9126,12 @@ export var NativeEventEmitter: NativeEventEmitter
export var NativeAppEventEmitter: RCTNativeAppEventEmitter
/**
* Empty interface which can be augmented by other type definitions for the NativeModules var below.
* Interface for NativeModules which allows to augment NativeModules with type informations.
* See react-native-sensor-manager for example.
*/
interface NativeModulesStatic {}
interface NativeModulesStatic {
[name: string]: any;
}
/**
* Native Modules written in ObjectiveC/Swift/Java exposed via the RCTBridge

View File

@@ -39,8 +39,24 @@ import {
ScrollViewProps,
RefreshControl,
TabBarIOS,
NativeModules
} from 'react-native';
declare module 'react-native' {
interface NativeTypedModule {
someFunction(): void;
someProperty: string;
}
interface NativeModulesStatic {
NativeTypedModule: NativeTypedModule
}
}
NativeModules.NativeUntypedModule;
NativeModules.NativeTypedModule.someFunction();
NativeModules.NativeTypedModule.someProperty = "";
function testDimensions() {
const {
width,