My objective is to create a sophisticated object, with values that need to be calculated or extracted from another object.
The specific object I am working on is defined as follows:
interface A extends B {
key1: string
key2: {
it's a complex object with multiple keys
}
}
I attempted the following code:
const a: A = Object.assign({}, b); // encountering a TypeScript error here
a.key1 = around 10 lines of calculations
a.key2 = around 10 lines of calculations
However, an error occurred stating
TS2741: Property 'key1, key2' is missing in type 'a' but required in type 'A'
.
Is there a method to establish an object across multiple lines without resorting to writing unreadable code like
Object.assign({}, b, {key1: 10line, key2: 10line})
?