In my code, I have defined two classes. One is called Stuff and the other is called Thing.
class Stuff {
constructor() { }
things: Thing[] = [];
name: string;
}
class Thing {
constructor() { }
active: boolean;
}
As I was working on my application, I attempted to declare a field using the following syntax.
blopp: Stuff[] = [
{name: "aa", things: null},
{name: "bb", things: null}];
Initially, this method worked perfectly fine. However, when I tried to assign an array of things instead of null, I encountered an error stating that it's not assignable to the specified type.
blopp: Stuff[] = [
{name: "aa", things: [{active: true}, {active: false}]},
{name: "bb", things: null}];