'Create a class instance from data in an object in typescript

I have a full example on the typescript website. Basically, the last line in this function is not working

export function getInvoice(number: number): Invoice | undefined {
    let jsonObj = invoices.find(
        (invoice) => invoice.number === number
    );
    if(!jsonObj)
        return jsonObj;
    jsonObj = Object.assign(Invoice.prototype, jsonObj);
    return jsonObj;
}

Invoice is an array of objects including invoice data. After I get the object back, I am trying to convert it into a typed Invoice object to use. The return jsonObj is erroring out for some reason with the error

TS2739: Type '{ name: string; number: number; amount: string; due: string; }' is missing the following properties from type 'Invoice': _name, _number, _amount, _due


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source