#Conditional type / inference returns never

10 messages · Page 1 of 1 (latest)

strange heartBOT
#
MoeagaruYuuki#0001

Preview:ts ... type Foo = MessageFieldsFromType<PrivateMessage>; // ^?

wintry zephyr
#

Why does this return never? From my understanding, it should clearly return PrivateMessageFields

#

I just noticed that it does work if I explicitly annotate PrivateMessage#paramSpec as MessageParamSpec<PrivateMessageFields>, but I don't really want to do that

#

I already write enough stuff twice as is

#

Got it - Record is really not my friend today

#

When I use mapped type syntax directly, it all works

tacit spindle
#

am i missing something? it seems not work even all Records are replaced to mapped type syntax (in the playground that you posted)

strange heartBOT
#
무언가#0213

Preview:```ts
export interface BaseMessageParamSpecEntry {
trailing?: boolean
}

export interface RequiredMessageParamSpecEntry
extends BaseMessageParamSpecEntry {
optional?: false
}

export interface OptionalMessageParamSpecEntry
extends BaseMessageParamSpecEntr
...```

wintry zephyr
#

Ah, apparently I dumbed it down too much

#

It works if Message contains a property of type Fields exactly