Preview:```ts
type Bar = {}
interface Foo {
(...args: any[]): Bar
}
const x: Foo = {
// how do you implement Foo?
}```
You can choose specific lines to embed by selecting them before copying the link.
19 messages · Page 1 of 1 (latest)
Preview:```ts
type Bar = {}
interface Foo {
(...args: any[]): Bar
}
const x: Foo = {
// how do you implement Foo?
}```
!ts
type Bar = {};
interface Foo {
(...args: any[]): Bar;
}
const x: Foo = {
// ^
// Type '{}' is not assignable to type 'Foo'.
// Type '{}' provides no match for the signature '(...args: any[]): Bar'.
// how do you implement Foo?
};
Is there a way to implement this with an object literal?
I don't know how to implement it regardless
It's a function
Okay.can you show me how to implement it?
I tried assuming it was a function, and still couldn't get it to compile
oh nm
const x: Foo = () => { return {}}
I guess it's not syntactically correct unless I wrap the body in curly braces
ah right. I forgot about that
okay thanks
!resolve
Actually, why would you define a function type through an interface?
is it only useful if you want to do fine other properties on the function?
you can define overloads as well