TypeScript kiểm tra extra properties khi assign object literal trực tiếp vào typed variable.
Nhưng assign qua biến trung gian không bị check — đây là behavior khá bất ngờ.
typescript
interface Config { host: string; port: number }
// Object literal — excess property check:
const cfg: Config = { host: 'localhost', port: 3000, debug: true }; // Error!
// Qua biến trung gian — không bị check:
const raw = { host: 'localhost', port: 3000, debug: true };
const cfg2: Config = raw; // OK (chỉ check structural compatibility)Behavior này giúp phát hiện typos trong config objects.