Open
Description
Bug Report
π Search Terms
Intellisense, incorrect function parameter
π Version & Regression Information
Tried with v4.3.5
β― Playground Link
π» Code
declare const send:
(event: { type: "A", foo: string } | { type: "B" } | "B") => void
declare const sendOnlyObject:
(event: { type: "A", foo: string } | { type: "B" }) => void
send({ type: "A" })
// Type '"A"' is not assignable to type '"B"'.(2322)
sendOnlyObject({ type: "A" })
// Argument of type '{ type: "A"; }' is not assignable to parameter of type '{ type: "A"; foo: string; } | { type: "B"; }'.
// Property 'foo' is missing in type '{ type: "A"; }' but required in type '{ type: "A"; foo: string; }'.(2345)
π Actual behavior
The error for send({ type: "A" })
is Type '"A"' is not assignable to type '"B"'
π Expected behavior
The error should be something like the one for sendOnlyObject
or at least not misleading that the property type
has to be "B"
that's what is getting suggested here.