# 04 · interface-vs-type **演示**:同名 `interface` 自动合并;`type` 别名不能合并但能表达联合/映射;`readonly` 与 `exactOptionalPropertyTypes` 的行为。 **运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开 `http://localhost:8080/examples/04-object-types-structural/04-interface-vs-type/`;开 Console。 **预期控制台输出**: ```text localhost:8080 1,2 demo ``` **类型检查**:`node node_modules/typescript/bin/tsc -p examples/04-object-types-structural/04-interface-vs-type/tsconfig.types.json` **注意**:负例分别验证 `readonly` 写入与显式 `undefined`(`TS2375`)都会报错。