MatthewWid / better-sse

⬆ Dead simple, dependency-less, spec-compliant server-sent events implementation for Node, written in TypeScript.
https://matthewwid.github.io/better-sse/
MIT License
558 stars 14 forks source link

Make `State` generic parameter extend `Record<string, any>` #45

Closed qpwo closed 2 years ago

qpwo commented 2 years ago

With Record<string, unknown>, you get a type error if you use an interface:

interface SessionState {
    id: string
}
const session = await createSession<SessionState>(req, res)
// Error:
// Type 'SessionState' does not satisfy the constraint 'Record<string, unknown>'.
//  Index signature for type 'string' is missing in type 'SessionState'.ts(2344)