You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The JSONObject-type (here) requires us to add an Index signature to all interfaces used in the defineEventHandler() return statement.
Forcing us to add [key: string]: any; to our Interfaces allows for errors later on.
Example:
interfaceProduct{
id: string
name: string}exportdefaultdefineEventHandler(async(_event)=>{// Error given at this point (See below)constproducts: Product[]=[]// Pretend we got some products from the databasereturn{
products,}})
# Error
Argument of type '(_event: CompatibilityEvent) => Promise<{ products: Product[]; }>' is not assignable to parameter of type 'EventHandler<H3Response>'.
Type 'Promise<{ products: Product[]; }>' is not assignable to type 'H3Response'.
Type 'Promise<{ products: Product[]; }>' is not assignable to type 'Promise<_H3Response>'.
Type '{ products: Product[]; }' is not assignable to type '_H3Response'.
Type '{ products: Product[]; }' is not assignable to type 'JSONObject'.
Property 'products' is incompatible with index signature.
Type 'Product[]' is not assignable to type 'JSONValue'.
Type 'Product[]' is not assignable to type 'JSONArray'.
Type 'Product' is not assignable to type 'JSONValue'.
Type 'Product' is not assignable to type 'JSONObject'.
Index signature fortype 'string' is missing intype 'Product'.ts(2345)
This would remove the error on our side. But this doesn't really represent our type and allows for more errors later on.
The JSONObject-type (here) requires us to add an Index signature to all interfaces used in the defineEventHandler() return statement.
Forcing us to add
[key: string]: any;
to our Interfaces allows for errors later on.Example:
This would remove the error on our side. But this doesn't really represent our type and allows for more errors later on.
The text was updated successfully, but these errors were encountered: