whaley
whaley2w ago

Deno KV Type narrowing issue

import { createDiscordOAuthConfig, createHelpers } from '@deno/kv-oauth'
import { env } from '../../../env.ts'

// Discord OAuth configuration for bot authorization
// This authorizes the bot to join and operate in Discord servers
const oauthConfig = createDiscordOAuthConfig({
redirectUri: [env.BASE_URL, '/oauth/discord/callback'].join(''),
scope: ['bot', 'applications.commands'], // Bot permissions
})

export const discordOAuthHelpers = createHelpers(oauthConfig)

export { oauthConfig as discordOAuthConfig }
import { createDiscordOAuthConfig, createHelpers } from '@deno/kv-oauth'
import { env } from '../../../env.ts'

// Discord OAuth configuration for bot authorization
// This authorizes the bot to join and operate in Discord servers
const oauthConfig = createDiscordOAuthConfig({
redirectUri: [env.BASE_URL, '/oauth/discord/callback'].join(''),
scope: ['bot', 'applications.commands'], // Bot permissions
})

export const discordOAuthHelpers = createHelpers(oauthConfig)

export { oauthConfig as discordOAuthConfig }
I'm setting up a discord bot for my application, so I can run bot automations when doing actions in the app. Some organizations will have bots, others won't, so it's critical that the session ID in deno kv oauth is string | undefined so I can guard correctly, right? I've investigated the deno kv and deno kv oauth 2 source code and I'm seeing explicit types that don't align with the actual return types. I'm not sure if I'm just missing some critical info or if this is a TypeScript LSP bug, or what's going on... Can someone clue me in? I might just be totally off-base and doing things totally wrong here.
No description
No description
1 Reply
Leokuma
Leokuma7d ago
Have you tried asking this at the kv-oauth repository? I think you might get a better answer there I just had a look at the repo and I'm not sure if this project is still being maintained

Did you find this page helpful?