因为 `const str = '2D'` 定义的是一个常量,不可能被修改,所以 str 的类型能自动推断为 `'2D'` 而 `const obj = { bbb: '2D' }` 中的 `bbb` 是一个可变成员, 所以只能往泛类型上推导成 `string` 这种场景最好用枚举 enum VmsType { '2D' = '2D', '3D' = '3D', lpo = 'lpo', lips = 'lips' } function func(type: VmsType) { console.log("🚀 ~ func ~ type:", type); } const str = VmsType["2D"]; const obj = { bbb: VmsType["2D"], ccc: 'test' }; // ok func(str); func(obj.bbb); // Argument of type 'string' is not assignable to parameter of type 'VmsType'. func(obj.ccc);