The literal type of select(getPathname) doesn’t relate to the value you get back from the yield. select(getPathname) is the value yielded by your co-routine to its iterating context.
The value injected into your generator by its running context (through the next() call) DOES matter to the type you get back from the yield expression.
Either way, currently Typescript has no metadata about what it’s going to get at all, since your generator function has no type annotation.
I’m guessing this is redux-saga.
A typical Generator function type annotation is something like…
type WhatYouYield="foo"
type WhatYouReturn="bar"
type WhatYouAccept="baz"
function* myfun(): Generator<
WhatYouYield,
WhatYouReturn,
WhatYouAccept
> {
const myYield = "foo" //type of myYield is WhatYouYield
const myAccepted = yield myYield; //type of myAccepted is WhatYouAccept
return "baz" //type of this value is WhatYouReturn
}
…and the error you’re getting is from Typescript having to guess the WhatYouAccept type without the Generator type annotation on your function.