Skip to content

Commit a70d32a

Browse files
authored
fix: improve autocomplete for session keys (#13622)
1 parent 0f1c109 commit a70d32a

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎.changeset/young-peaches-serve.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Improve autocomplete for session keys

‎packages/astro/src/core/session.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class AstroSession<TDriver extends SessionDriverName = any> {
102102
/**
103103
* Gets a session value. Returns `undefined` if the session or value does not exist.
104104
*/
105-
async get<T = void, K extends string = string>(
105+
async get<T = void, K extends string = keyof App.SessionData | (string & {}) >(
106106
key: K,
107107
): Promise<
108108
(T extends void ? (K extends keyof App.SessionData ? App.SessionData[K] : any) : T) | undefined
@@ -153,7 +153,7 @@ export class AstroSession<TDriver extends SessionDriverName = any> {
153153
* Sets a session value. The session is created if it does not exist.
154154
*/
155155

156-
set<T = void, K extends string = string>(
156+
set<T = void, K extends string = keyof App.SessionData | (string & {})>(
157157
key: K,
158158
value: T extends void
159159
? K extends keyof App.SessionData

0 commit comments

Comments
 (0)