TypeScript | 天(没)马(什)行(么)空(用)的TS指南 | 01 - ”都得按规矩来” Caspian 2022-03-24 112 阅读1分钟 设置儿子的名字,当然爸爸的名字是串文字,儿子也得是。 const fatherName = "大壮"; function setSonName (name: typeof FatherName){ return name } setSonName(2) // ❌ setSonName("二壮") // ✅