Skip to content

Commit edeb381

Browse files
authored
chore(plugin-stripe): enable TypeScript strict (#12303)
1 parent c43891b commit edeb381

File tree

7 files changed

+11
-23
lines changed

7 files changed

+11
-23
lines changed

packages/plugin-stripe/src/hooks/createNewInStripe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const createNewInStripe: CollectionBeforeValidateHookWithArgs = async (ar
6161
syncedFields = deepen(syncedFields)
6262

6363
// api version can only be the latest, stripe recommends ts ignoring it
64-
const stripe = new Stripe(pluginConfig.stripeSecretKey || '', { apiVersion: '2022-08-01' })
64+
const stripe = new Stripe(pluginConfig?.stripeSecretKey || '', { apiVersion: '2022-08-01' })
6565

6666
if (operation === 'update') {
6767
if (logs) {

packages/plugin-stripe/src/hooks/deleteFromStripe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const deleteFromStripe: CollectionAfterDeleteHookWithArgs = async (args)
4040
if (syncConfig) {
4141
try {
4242
// api version can only be the latest, stripe recommends ts ignoring it
43-
const stripe = new Stripe(pluginConfig.stripeSecretKey || '', { apiVersion: '2022-08-01' })
43+
const stripe = new Stripe(pluginConfig?.stripeSecretKey || '', { apiVersion: '2022-08-01' })
4444

4545
const found = await stripe?.[syncConfig.stripeResourceType]?.retrieve(doc.stripeID)
4646

packages/plugin-stripe/src/hooks/syncExistingWithStripe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const syncExistingWithStripe: CollectionBeforeChangeHookWithArgs = async
6363

6464
try {
6565
// api version can only be the latest, stripe recommends ts ignoring it
66-
const stripe = new Stripe(pluginConfig.stripeSecretKey || '', {
66+
const stripe = new Stripe(pluginConfig?.stripeSecretKey || '', {
6767
apiVersion: '2022-08-01',
6868
})
6969

packages/plugin-stripe/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const stripePlugin =
5959
})
6060
}
6161

62-
for (const collection of collections) {
62+
for (const collection of collections!) {
6363
const { hooks: existingHooks } = collection
6464

6565
const syncConfig = pluginConfig.sync?.find((sync) => sync.collection === collection.slug)

packages/plugin-stripe/src/routes/rest.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ export const stripeREST = async (args: {
1818
await addDataAndFileToRequest(req)
1919

2020
const requestWithData = req
21-
22-
const {
23-
data: {
24-
stripeArgs, // example: ['cus_MGgt3Tuj3D66f2'] or [{ limit: 100 }, { stripeAccount: 'acct_1J9Z4pKZ4Z4Z4Z4Z' }]
25-
stripeMethod, // example: 'subscriptions.list',
26-
},
27-
payload,
28-
user,
29-
} = requestWithData
21+
const { data, payload, user } = requestWithData
3022

3123
const { stripeSecretKey } = pluginConfig
3224

@@ -37,8 +29,8 @@ export const stripeREST = async (args: {
3729
}
3830

3931
responseJSON = await stripeProxy({
40-
stripeArgs,
41-
stripeMethod,
32+
stripeArgs: data?.stripeArgs, // example: ['cus_MGgt3Tuj3D66f2'] or [{ limit: 100 }, { stripeAccount: 'acct_1J9Z4pKZ4Z4Z4Z4Z' }]
33+
stripeMethod: data?.stripeMethod, // example: 'subscriptions.list',
4234
stripeSecretKey,
4335
})
4436

packages/plugin-stripe/src/routes/webhooks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const stripeWebhooks = async (args: {
2626
},
2727
})
2828

29-
const body = await req.text()
29+
const body = await req.text!()
3030
const stripeSignature = req.headers.get('stripe-signature')
3131

3232
if (stripeSignature) {
@@ -41,7 +41,7 @@ export const stripeWebhooks = async (args: {
4141
}
4242

4343
if (event) {
44-
handleWebhooks({
44+
void handleWebhooks({
4545
config,
4646
event,
4747
payload: req.payload,
@@ -52,7 +52,7 @@ export const stripeWebhooks = async (args: {
5252

5353
// Fire external webhook handlers if they exist
5454
if (typeof webhooks === 'function') {
55-
webhooks({
55+
void webhooks({
5656
config,
5757
event,
5858
payload: req.payload,
@@ -65,7 +65,7 @@ export const stripeWebhooks = async (args: {
6565
if (typeof webhooks === 'object') {
6666
const webhookEventHandler = webhooks[event.type]
6767
if (typeof webhookEventHandler === 'function') {
68-
webhookEventHandler({
68+
void webhookEventHandler({
6969
config,
7070
event,
7171
payload: req.payload,

packages/plugin-stripe/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"compilerOptions": {
4-
/* TODO: remove the following lines */
5-
"strict": false,
6-
},
73
"references": [{ "path": "../payload" }, { "path": "../ui" }, { "path": "../next" }]
84
}

0 commit comments

Comments
 (0)