Skip to content

Commit

Permalink
fix: type errors in iapexample
Browse files Browse the repository at this point in the history
now properly linked with parent project
  • Loading branch information
arthurgeron committed Nov 13, 2023
1 parent bd2e42e commit cad1d90
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 32 deletions.
8 changes: 4 additions & 4 deletions IapExample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
"@react-navigation/stack": "^6.2.0",
"lodash": "4.17.21",
"react": "18.2.0",
"react-native": "^0.72.6",
"react-native": "0.72.6",
"react-native-gesture-handler": "^2.12.0",
"react-native-iap": "portal:../",
"react-native-safe-area-context": "^4.5.3",
"react-native-screens": "^3.21.0"
},
Expand All @@ -29,7 +30,7 @@
"@react-native/metro-config": "^0.72.11",
"@tsconfig/react-native": "^3.0.0",
"@types/lodash": "4.14.191",
"@types/react": "^18.0.24",
"@types/react": "18.0.24",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
"babel-plugin-module-resolver": "5.0.0",
Expand All @@ -39,8 +40,7 @@
"typescript": "4.8.4"
},
"resolutions": {
"@types/react": "17.0.53",
"@types/react-native": "0.68.2"
"@types/react": "18.0.24"
},
"engines": {
"node": ">=16"
Expand Down
27 changes: 21 additions & 6 deletions IapExample/src/screens/ClassSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ export class ClassSetup extends Component<{}, State> {
}
} catch (error) {
if (error instanceof PurchaseError) {
errorLog({message: `[${error.code}]: ${error.message}`, error});
errorLog({
message: `[${(error as PurchaseError).code}]: ${
(error as PurchaseError).message
}`,
error,
});
} else {
errorLog({message: 'finishTransaction', error});
}
Expand All @@ -103,15 +108,15 @@ export class ClassSetup extends Component<{}, State> {
this.setState({receipt}, () => this.goNext());
}
},
);
) as unknown as EmitterSubscription;

this.purchaseError = purchaseErrorListener((error: PurchaseError) => {
Alert.alert('purchase error', JSON.stringify(error));
});
}) as unknown as EmitterSubscription;;

this.promotedProduct = promotedProductListener((productId?: string) =>
Alert.alert('Product promoted', productId),
);
) as unknown as EmitterSubscription;;
}
componentWillUnmount() {
this.purchaseUpdate?.remove();
Expand Down Expand Up @@ -167,7 +172,12 @@ export class ClassSetup extends Component<{}, State> {
requestPurchase({sku});
} catch (error) {
if (error instanceof PurchaseError) {
errorLog({message: `[${error.code}]: ${error.message}`, error});
errorLog({
message: `[${(error as PurchaseError).code}]: ${
(error as PurchaseError).message
}`,
error,
});
} else {
errorLog({message: 'requestPurchase', error});
}
Expand All @@ -179,7 +189,12 @@ export class ClassSetup extends Component<{}, State> {
requestSubscription({sku});
} catch (error) {
if (error instanceof PurchaseError) {
errorLog({message: `[${error.code}]: ${error.message}`, error});
errorLog({
message: `[${(error as PurchaseError).code}]: ${
(error as PurchaseError).message
}`,
error,
});
} else {
errorLog({message: 'requestSubscription', error});
}
Expand Down
8 changes: 7 additions & 1 deletion IapExample/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"extends": "@tsconfig/react-native/tsconfig.json"
"extends": "@tsconfig/react-native/tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"paths": {
"react-native-iap": ["../src/index"]
},
}
}
Loading

0 comments on commit cad1d90

Please sign in to comment.