Generate typed dictionary with a for loop using an enum as key type but without using `?` to mark undefined in TypeScript
问题 The problem is that I want to use enum as key for a dictionary but I want to dynamically generate the entries using a loop. But I will prefer not to use ? operator because I know I'll fill all keys and I don't want to force ! evaluation for each call. enum Students { A, B, C, // many many students } // class Info(); // some properties like grades and teacher const studentInfo: { [key in Students]: Info }; // won't work const must be initialized const studentInfo: { [key in Students]: Info } =