79722233

Date: 2025-08-01 08:26:45
Score: 0.5
Natty:
Report link

use generics:

interface A {
  a: string;
}


function createArray<T extends A>(arr: T[]): A[] {
    return arr;
}

function pushElement<T extends A>(arr: A[], value: T) {
    arr.push(value);
}



const a: A[] = createArray([{ a: "a" }, { a: "a", b: "b" }]);

pushElement(a, { a: "a", c: "b" })
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Alexandroppolus