Concat
introduction#
Implement the JavaScript Array.concat function in the type system. A type takes the two arguments. The output should be a new array that includes inputs in ltr order
For example
tstype Result = Concat<[1], [2]>; // expected to be [1, 2]
View on GitHubtstype Result = Concat<[1], [2]>; // expected to be [1, 2]
start point#
tsTry/* _____________ Your Code Here _____________ */typeConcat <T ,U > = any;Â/* _____________ Test Cases _____________ */typecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Concat <[], []>, []>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Concat <[], [1]>, [1]>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Concat <[1, 2], [3, 4]>, [1, 2, 3, 4]>>,Expect <Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Equal <Concat <['1', 2, '3'], [false, boolean, '4']>,['1', 2, '3', false, boolean, '4']>>];
take the challengetake the challengetsTry/* _____________ Your Code Here _____________ */typeConcat <T ,U > = any;Â/* _____________ Test Cases _____________ */typecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Concat <[], []>, []>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Concat <[], [1]>, [1]>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Concat <[1, 2], [3, 4]>, [1, 2, 3, 4]>>,Expect <Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Equal <Concat <['1', 2, '3'], [false, boolean, '4']>,['1', 2, '3', false, boolean, '4']>>];