Closed
Description
Bug Report
if there is an union type contains over 20 type, it will failed to assign the data to its property with the same type, even by itself.
🔎 Search Terms
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about 4.5.2
and I also check next and nightly version, the bug still exist
⏯ Playground Link
💻 Code
type A = { type: "A" };
type B = { type: "B" };
type C = { type: "C" };
type D = { type: "D" };
type E = { type: "E" };
type F = { type: "F" };
type G = { type: "G" };
type H = { type: "H" };
type I = { type: "I" };
type J = { type: "J" };
type K = { type: "K" };
type L = { type: "L" };
type M = { type: "M" };
type N = { type: "N" };
type O = { type: "O" };
type P = { type: "P" };
type Q = { type: "Q" };
type R = { type: "R" };
type S = { type: "S" };
type T = { type: "T" };
type U = { type: "U" };
type V = { type: "V" };
type W = { type: "W" };
type X = { type: "X" };
type Y = { type: "Y" };
type Z = { type: "Z" };
type A1 = { type: "A" };
type B1 = { type: "B" };
type C1 = { type: "C" };
type D1 = { type: "D" };
type E1 = { type: "E" };
type F1 = { type: "F" };
type G1 = { type: "G" };
type H1 = { type: "H" };
type I1 = { type: "I" };
type J1 = { type: "J" };
type K1 = { type: "K" };
type L1 = { type: "L" };
type M1 = { type: "M" };
type N1 = { type: "N" };
type O1 = { type: "O" };
type P1 = { type: "P" };
type Q1 = { type: "Q" };
type R1 = { type: "R" };
type S1 = { type: "S" };
type T1 = { type: "T" };
type U1 = { type: "U" };
type V1 = { type: "V" };
type W1 = { type: "W" };
type X1 = { type: "X" };
type Y1 = { type: "Y" };
type Z1 = { type: "Z" };
type union = A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z;
type union1 = A1|B1|C1|D1|E1|F1|G1|H1|I1|J1|K1|L1|M1|N1|O1|P1|Q1|R1|S1|T1|U1|V1|W1|X1|Y1|Z1;
// error
const foo = (x: union1): union => {
return {
type: x.type,
};
};
const bar = (x: union1): union => {
return x;
};
const xyz = (): union => {
return {
type: "A",
};
};
//error
const abc = (x: union1): union => {
return {
type: x.type as union["type"],
};
};
type shrinkUnion = A | B | C | D;
type shrinkUnion1 = A1 | B1 | C1 | D1;
const foo1 = (x: shrinkUnion1): shrinkUnion => {
return {
type: x.type,
};
};
const bar1 = (x: shrinkUnion1): shrinkUnion => {
return x;
};
const xyz1 = (): union => {
return {
type: "A",
};
};
const abc1 = (x: shrinkUnion1): shrinkUnion => {
return {
type: x.type as shrinkUnion["type"],
};
};
🙁 Actual behavior
failed to assign union1['type'] | union['type']
to union's type
🙂 Expected behavior
it should enable the assignment;