π Search Terms
Object.assign, union
π Version & Regression Information
- I have only tried this in version 6.0.3
β― Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBKkPrAgZ2A80C8UBEATA9gLbZQA+OYATvgB4jYDcAUAJYB2ilAZgIYDG0RCjgAbFsIKEoEGoja4kUAIKVKPEAB4UldgHMA2gF0AfFADeTKFahsehCAC4o2vc2sx0T2BATJU35gBfJiY+fDYUKB5VKCwAeQAjACsIPmAAOh4kJBZdNgAKS2sjABoiqwt3d1t7J2wkImgXNl1sMqrrbzqqWnpyqGCASgYgA
π» Code
type type_test_type = "dom" | "proxy";
interface test_list_dom extends Array<string[]> {
name: string;
type: type_test_type;
}
const arr = Object.assign(
[],
{
name: "some string",
type: "proxy"
}
);
π Actual behavior
Type 'string' is not assignable to type 'type_test_type'.
π Expected behavior
No issue.
Additional information about the issue
Yes, I can easily suppress the error by using: type: "proxy" as type_test_type but in all other cases of union types a matching value is recognized as a member of the union.
The provided code sample is simplified from the actual code in my repository generating the issue. I cannot generate this issue from either code in the TypeScript Playground.
π Search Terms
Object.assign, union
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBKkPrAgZ2A80C8UBEATA9gLbZQA+OYATvgB4jYDcAUAJYB2ilAZgIYDG0RCjgAbFsIKEoEGoja4kUAIKVKPEAB4UldgHMA2gF0AfFADeTKFahsehCAC4o2vc2sx0T2BATJU35gBfJiY+fDYUKB5VKCwAeQAjACsIPmAAOh4kJBZdNgAKS2sjABoiqwt3d1t7J2wkImgXNl1sMqrrbzqqWnpyqGCASgYgA
π» Code
π Actual behavior
Type 'string' is not assignable to type 'type_test_type'.
π Expected behavior
No issue.
Additional information about the issue
Yes, I can easily suppress the error by using:
type: "proxy" as type_test_typebut in all other cases of union types a matching value is recognized as a member of the union.The provided code sample is simplified from the actual code in my repository generating the issue. I cannot generate this issue from either code in the TypeScript Playground.