Open
Description
🔎 Search Terms
aliases lost
🕗 Version & Regression Information
Discussion with @Andarist:
- TypeFormatFlags.InTypeAlias is at fault here, it's rather hard to track its exact conceptual purpose. And it has been there forever - I found commits with it from 9 years ago
- I briefly thought this might be related to ur issue: Type alias printing regressed in TypeScript 4.2.2 #43031
but now I'm pretty sure it isn't - but it's also a somewhat funny issue because it complains about an alias for a union being lost and it was broken by a PR that... introduces improved union/intersection aliasing 😄 Preserve type aliases for union and intersection types #42149 , there was also a quick follow up to this PR that feels slightly related: Support re-aliasing of type alias instantiations #42284
Anyway, I'm sort of leaving breadcrumbs for myself - sorry for oversharing 😉 I'll dig further later
⏯ Playground Link
💻 Code
type Result<A, E> = {
readonly _tag: "Ok"
readonly value: A
} | {
readonly _tag: "Fail"
readonly error: E
}
declare const isResult: (u: unknown) => u is Result<any, any>
const fn = <A, E>(inp: Result<A, E> | string) => isResult(inp) ? inp : "ok"
🙁 Actual behavior
const fn: <A, E>(inp: Result<A, E> | string) => {
readonly _tag: "Ok";
readonly value: A;
} | {
readonly _tag: "Fail";
readonly error: E;
} | "ok"
🙂 Expected behavior
const fn: <A, E>(inp: Result<A, E> | string) => Result<A, E> | "ok"
Additional information about the issue
No response