refactor: ♻️ remove unnecessary unknown extends in generic

This commit is contained in:
Julien Oculi 2024-06-17 12:43:00 +02:00
parent e44401415a
commit 021d9e689b

View file

@ -1,7 +1,7 @@
import type { PageProps } from '$fresh/server.ts' import type { PageProps } from '$fresh/server.ts'
import { getCookies } from '@std/http/cookie' import { getCookies } from '@std/http/cookie'
type SessionEntry<T extends unknown = unknown> = { type SessionEntry<T = unknown> = {
accessCount: number accessCount: number
flash: boolean flash: boolean
value: T value: T
@ -84,7 +84,7 @@ class Session {
return this.#timestamp return this.#timestamp
} }
get<T extends unknown = unknown>(key: string): T | undefined { get<T = unknown>(key: string): T | undefined {
this.#updateTimestamp() this.#updateTimestamp()
const entry = this.#db.get(key) const entry = this.#db.get(key)
@ -103,7 +103,7 @@ class Session {
this.#db.set(key, entry) this.#db.set(key, entry)
return entry.value as T return entry.value as T
} }
set<T extends unknown = unknown>(key: string, value: T): void { set<T = unknown>(key: string, value: T): void {
this.#updateTimestamp() this.#updateTimestamp()
const entry = this.#db.get(key) as SessionEntry<T> | undefined const entry = this.#db.get(key) as SessionEntry<T> | undefined
@ -132,7 +132,7 @@ class Session {
const keys = [...this.#db.keys()] const keys = [...this.#db.keys()]
return keys.map((key) => ([key, this.get(key)] as [string, unknown])) return keys.map((key) => ([key, this.get(key)] as [string, unknown]))
} }
flash<T extends unknown = unknown>(key: string, value: T) { flash<T = unknown>(key: string, value: T) {
this.#updateTimestamp() this.#updateTimestamp()
const entry = this.#db.get(key) as SessionEntry<T> | undefined const entry = this.#db.get(key) as SessionEntry<T> | undefined