kingworld
kingworld copied to clipboard
Context doesn't type null
import KingWorld from 'kingworld';
type Data = {
field: number;
}
const app = new KingWorld()
.state<'result', Data | null>('result', null)
.get('/', context => context.store.result.field)
.listen(3000);
console.log(`🦊 KINGWORLD is running at :${app.server.port}`);
Context is typed as the following.
(parameter) context: Context<TypedSchemaToRoute<MergeSchema<{}, {}>>, {
result: Data;
}>
result
should be typed as Data | null
.
Currently if I run this I get the following error when browsing to http://localhost:3000
.
null is not an object (evaluating 'context.store.result.field')