Type errors when using 6.0.1 and React Native 0.72.7
SMJ93 opened this issue ยท 5 comments
Hi! ๐
Firstly, thanks for your work on this project! ๐
Today I used patch-package to patch react-native-applovin-max@6.0.1
for the project I'm working on.
When using react-native-applovin-max
with "react-native": "0.72.7"
there are several type errors. This patch fixes those errors.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-applovin-max/src/AdView.tsx b/node_modules/react-native-applovin-max/src/AdView.tsx
index 8d29d91..ff22f62 100644
--- a/node_modules/react-native-applovin-max/src/AdView.tsx
+++ b/node_modules/react-native-applovin-max/src/AdView.tsx
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import { NativeModules, requireNativeComponent, StyleSheet } from "react-native";
-import type { ViewProps, ViewStyle, StyleProp } from "react-native";
+import type { ViewProps, ViewStyle, StyleProp, DimensionValue } from "react-native";
import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo, AdRevenueInfo } from "./types/AdInfo";
import type { AdNativeEvent } from "./types/AdEvent";
import type { AdViewProps } from "./types/AdViewProps";
@@ -76,7 +76,7 @@ const getOutlineViewSize = (style: StyleProp<ViewStyle>) => {
return [viewStyle?.width, viewStyle?.height];
};
-const sizeAdViewDimensions = (adFormat: AdFormat, adaptiveBannerEnabled?: boolean, width?: number | string, height?: number | string): Promise<{}> => {
+const sizeAdViewDimensions = (adFormat: AdFormat, adaptiveBannerEnabled?: boolean, width?: number | string | DimensionValue, height?: number | string | DimensionValue): Promise<{}> => {
const sizeForBannerFormat = async () => {
const isTablet = await AppLovinMAX.isTablet();
diff --git a/node_modules/react-native-applovin-max/src/TargetingData.ts b/node_modules/react-native-applovin-max/src/TargetingData.ts
index d38831d..3ac87aa 100644
--- a/node_modules/react-native-applovin-max/src/TargetingData.ts
+++ b/node_modules/react-native-applovin-max/src/TargetingData.ts
@@ -160,7 +160,7 @@ export const TargetingData: TargetingDataType = {
/**
* Sets the keywords describing the application. Set this to null to clear this value.
*/
- set keywords(value: string[] | null | Promise<string[]> | null) {
+ set keywords(value: string[] | null | Promise<string[] | null>) {
if (value === null) {
nativeMethods.setTargetingDataKeywords(null);
} else if (isStringArray(value)) {
diff --git a/node_modules/react-native-applovin-max/src/types/TargetingData.ts b/node_modules/react-native-applovin-max/src/types/TargetingData.ts
index 41fd251..0214654 100644
--- a/node_modules/react-native-applovin-max/src/types/TargetingData.ts
+++ b/node_modules/react-native-applovin-max/src/types/TargetingData.ts
@@ -1,4 +1,4 @@
-import type { AdContentRating, UserGender } from "src/TargetingData";
+import type { AdContentRating, UserGender } from "../TargetingData";
/**
* Defines additional data for the publisher to send to AppLovin.
This issue body was partially generated by patch-package.
@SMJ93, thanks a lot for raising the issue with their fixes. We will integrate them in the next release ๐
@SMJ93, this is a list of your issues.
- DimensionValue
- TargetingData keywords type
- TargingData import path
Again, thanks - we have integrated 2 and 3. Now I have a question about 1.
Our @types/react-native
has not exported DimensionValue
since we are using the old version - we want to stay behind to support widely. Can you let us know what errors you have without DimensionValue
?
React Native defines DimensionValue
:
export type DimensionValue = null | number | string | AnimatedNode;
Can supporting null for the width and height fix it?
Hi @SMJ93,
I've just updated to "react-native-applovin-max": "^6.0.2",
, but still have the following type errors:
$ tsc -p tsconfig.json
node_modules/react-native-applovin-max/src/AdView.tsx:197:63 - error TS2345: Argument of type 'DimensionValue | undefined' is not assignable to parameter of type 'string | number | undefined'.
Type 'null' is not assignable to type 'string | number | undefined'.
197 sizeAdViewDimensions(adFormat, adaptiveBannerEnabled, width, height).then((value: Record<string, number>) => {
~~~~~
Found 1 error in node_modules/react-native-applovin-max/src/AdView.tsx:197
I fixed it with the following patch:
diff --git a/node_modules/react-native-applovin-max/src/AdView.tsx b/node_modules/react-native-applovin-max/src/AdView.tsx
index 1ccbac2..a948a9c 100644
--- a/node_modules/react-native-applovin-max/src/AdView.tsx
+++ b/node_modules/react-native-applovin-max/src/AdView.tsx
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { NativeModules, requireNativeComponent, StyleSheet } from 'react-native';
-import type { ViewProps, ViewStyle, StyleProp } from 'react-native';
+import type { ViewProps, ViewStyle, StyleProp, DimensionValue } from 'react-native';
import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo, AdRevenueInfo } from './types/AdInfo';
import type { AdNativeEvent } from './types/AdEvent';
import type { AdViewProps } from './types/AdViewProps';
@@ -78,8 +78,8 @@ const getOutlineViewSize = (style: StyleProp<ViewStyle>) => {
const sizeAdViewDimensions = (
adFormat: AdFormat,
adaptiveBannerEnabled?: boolean,
- width?: number | string,
- height?: number | string
+ width?: number | string | DimensionValue,
+ height?: number | string | DimensionValue
): Promise<Record<string, number>> => {
const sizeForBannerFormat = async () => {
const isTablet = await AppLovinMAX.isTablet();
@SMJ93, would you mind sending us your tsconfig
? Also, this would suffice to suppress the error. Would you try this out?
+ width?: number | string | null,
+ height?: number | string | null
Sorry @alhiwatan - I've been off the last couple of weeks. I've just updated to 6.1.0 and all of the types work as expected ๐