kingworld icon indicating copy to clipboard operation
kingworld copied to clipboard

Context doesn't type null

Open OmgImAlexis opened this issue 1 year ago • 2 comments

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')

OmgImAlexis avatar Nov 22 '22 22:11 OmgImAlexis