-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed as not planned
Closed as not planned
Copy link
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options
Description
Bug Report
π Search Terms
union, generic, nested, nested, complex
π Version & Regression Information
- This is the behavior in every version I tried. I read through the FAQ and couldn't find relevant sections.
β― Playground Link
Playground link with relevant code
π» Code
type Test<T> = {
test: T
}
declare let outer: Test<Test<"a">> | Test<Test<"b">>
declare let inner: Test<Test<"a" | "b">>
inner = outer // this is accepted
outer = inner // this is not
π Actual behavior
The assignment outer = inner
fails following error
Type 'Test<Test<"a" | "b">>' is not assignable to type 'Test<Test<"a">> | Test<Test<"b">>'.
Type 'Test<Test<"a" | "b">>' is not assignable to type 'Test<Test<"a">>'.
Type 'Test<"a" | "b">' is not assignable to type 'Test<"a">'.
Type '"a" | "b"' is not assignable to type '"a"'.
Type '"b"' is not assignable to type '"a"'.(2322)
π Expected behavior
As far as I can tell, it should be accepted, but the type checker isn't quite smart enough. This issue came up in a larger real world example, but this was the minimal reproduction I could think of.
Metadata
Metadata
Assignees
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options