typeScript学习
字面量数据类型:
// type A = number | string // let a:A = "abc" // type num = number // let n:num = 3 type num = 1 | 2 | 3 let n:num = 2 // 错误情况 // let n:num = 4 type increaseFlag = 0 | 1 function isStartUp(increase:increaseFlag){ if(increase){ console.log('open') }else{ console.log('close') } } isStartUp(0) // 错误情况 // isStartUp(2)
标签:typeScript,isStartUp,数据类型,TS,num,let,type From: https://www.cnblogs.com/kongbaige/p/17622321.html