#Error: '?' expected. ts(1005)
12 messages · Page 1 of 1 (latest)
extends isn't valid there.
ah ok
Perhaps you want CustomEvent & { detail: string }.
I'd like it to be a CustomEvent but I'd like it to also have a details property.
This gives me:
Argument of type '(e: CustomEvent & { name: string; detail: string;}) => void' is not assignable to parameter of type '(e: CustomEvent<any>) => void'.
Types of parameters 'e' and 'e' are incompatible.
Type 'CustomEvent<any>' is not assignable to type 'CustomEvent<any> & { name: string; detail: string; }'.
Property 'name' is missing in type 'CustomEvent<any>' but required in type '{ name: string; detail: string; }'.ts(2345)
const eventHandler: (e: CustomEvent & {
name: string;
detail: string;
}) => void
CustomEvent<string> & { name: string }
the generic is used for the detail type
error
Argument of type '(e: CustomEvent<string> & { name: string;}) => void' is not assignable to parameter of type '(e: CustomEvent<any>) => void'.
Types of parameters 'e' and 'e' are incompatible.
Type 'CustomEvent<any>' is not assignable to type 'CustomEvent<string> & { name: string; }'.
Property 'name' is missing in type 'CustomEvent<any>' but required in type '{ name: string; }'.ts(2345)
const eventHandler: (e: CustomEvent<string> & {
name: string;
}) => void
where
The issue is the place you're assigning doesn't claim to have a name property attached to the error.