#Function parameters - extending interface parameter

4 messages · Page 1 of 1 (latest)

dawn knot
#

I'm trying to do something like this:

interface BaseParameters {
    a: string;
    b: number;
}

function functionA(body: {
    foo: string;
} extends BaseParameters) {
    // do something
}

To accomplish this:

function functionB(body: {
    foo: string;
    a: string;
    b: number;
}) {
    // do something
}

I'm getting this error which I can't make sense of: '?' expected.ts(1005)
Is it possible to accomplish what I'm trying to do or do I have to do it like this?

interface BaseParameters {
    a: string;
    b: number;
}

interface FunctionParameters extends BaseParameters {
    foo: string;
}

function functionA(body: FunctionParameters) {
    // do something
}
jagged summit
#

!hb intersection

timber cragBOT
dawn knot
#

Awesome, thank you very much!