[typings] Fix some admob type issues

This commit is contained in:
Chris Bianca 2017-12-06 16:42:21 +00:00
parent 9a9a7d47aa
commit e697f11641
1 changed files with 18 additions and 7 deletions

View File

@ -16,11 +16,22 @@ import EventTypes, {
RewardedVideoEventTypes,
} from './EventTypes';
import type FirebaseApp from '../core/firebase-app';
type NativeEvent = {
adUnit: string,
payload: Object,
type: string,
}
export default class AdMob extends ModuleBase {
static _NAMESPACE = 'admob';
static _NATIVE_MODULE = 'RNFirebaseAdMob';
constructor(firebaseApp: Object, options: Object = {}) {
_appId: ?string;
_initialized: boolean;
constructor(firebaseApp: FirebaseApp, options: Object = {}) {
super(firebaseApp, options, true);
this._initialized = false;
@ -30,7 +41,7 @@ export default class AdMob extends ModuleBase {
this._eventEmitter.addListener('rewarded_video_event', this._onRewardedVideoEvent.bind(this));
}
_onInterstitialEvent(event) {
_onInterstitialEvent(event: NativeEvent): void {
const { adUnit } = event;
const jsEventType = `interstitial_${adUnit}`;
@ -41,7 +52,7 @@ export default class AdMob extends ModuleBase {
this.emit(jsEventType, event);
}
_onRewardedVideoEvent(event) {
_onRewardedVideoEvent(event: NativeEvent): void {
const { adUnit } = event;
const jsEventType = `rewarded_video_${adUnit}`;
@ -52,7 +63,7 @@ export default class AdMob extends ModuleBase {
this.emit(jsEventType, event);
}
initialize(appId: string) {
initialize(appId: string): void {
if (this._initialized) {
this.log.warn('AdMob has already been initialized!');
} else {
@ -62,7 +73,7 @@ export default class AdMob extends ModuleBase {
}
}
openDebugMenu() {
openDebugMenu(): void {
if (!this._initialized) {
this.log.warn('AdMob needs to be initialized before opening the dev menu!');
} else {
@ -71,11 +82,11 @@ export default class AdMob extends ModuleBase {
}
}
interstitial(adUnit: string) {
interstitial(adUnit: string): Interstitial {
return new Interstitial(this, adUnit);
}
rewarded(adUnit: string) {
rewarded(adUnit: string): RewardedVideo {
return new RewardedVideo(this, adUnit);
}