Skip to content

Commit 2b70e90

Browse files
authoredJul 11, 2024··
fix(publish): better GitHub API type-safety (#122)
1 parent 7aa7028 commit 2b70e90

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed
 

‎packages/config/src/publish/index.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,14 @@ export const publish = async (options) => {
307307
},
308308
},
309309
)
310-
const data = /** @type {{items: Array<{login: string}>}} */ (
311-
await res.json()
312-
)
313-
if (data.items.length && data.items[0]) {
314-
username = data.items[0].login
310+
const data = /** @type {unknown} */ (await res.json())
311+
if (data && typeof data === 'object' && 'items' in data) {
312+
if (Array.isArray(data.items) && data.items[0]) {
313+
const item = /** @type {object} */ (data.items[0])
314+
if ('login' in item && typeof item.login === 'string') {
315+
username = item.login
316+
}
317+
}
315318
}
316319
}
317320

0 commit comments

Comments
 (0)
Please sign in to comment.