Q:

Optional parameter in a spread object

I have the following definition:
interface A {
    new ({a, b?, c});
}

It fails compilation due to the optional b parameter:
error TS1005: ',' expected.
error TS1180: Property destructuring pattern expected.

Removing the ? makes it compile.
How is it possible to express the optional parameter without extracting the spread object into a different type?

A:

What you have doesn't describe the types of a, b, and c.
You should notice they are all typed as any.
To specify their type, you need to have the type information, such as
interface A {
    new ({a, b, c}: { a: string, b?: string, c: string});
}

There's where you can specify b is optional.

