#How to apply argument type when trying to get return type of function?

1 messages · Page 1 of 1 (latest)

late birch
#

I am making multi type handler structure where each handler has specific item it supports. Then there is main registry which holds all handlers and you can get each specific handler, but I would like to get the handler through main registry instead of getting type handler and then getting handler, it works in some way but I am loosing ability to set specific type to returned handler.

Is it possible or I am asking too much from Typescript? 😄

unique swanBOT
#
aurimasniekis#0

Preview:```ts
interface Item {
type: string
}

interface FooItem extends Item {
type: "foo"
foo: string
}

interface Foo2Item extends FooItem {
zoo: number
}

interface BarItem extends Item {
type: "bar"
bar: number
}

interface Bar2Item extends BarItem
...```