当前位置:网站首页>typescript的type
typescript的type
2022-06-26 06:18:00 【前端一枚】
type的常用寫法:
//未使用type
let sum:(x:number,y:number) => number
sum=(x,y)=>x+y
const result = sum(1,2)
console.log(result)
//使用type
type PlusType=(x:number,y:number)=>number
let sum2:PlusType=(x,y)=>x+y
const result2=sum2(2,3)
console.log(result2)
// type結合聯合類型
type strOrNum=string|number
let result3:strOrNum='12'
result3=12
//比較常用
type Directions='Up'|'Down'|'Left'|'Right'
let toWhere:Directions='Down'
//type結合接口
interface IName{name:string}
type IPerson=IName&{age:number}
let person:IPerson={name:'jim',age:123}边栏推荐
猜你喜欢

技术能力的思考和总结

Transformer中的Self-Attention以及Multi-Head Self-Attention(MSA)
![[intra group questions semester summary] some reference questions for beginners](/img/39/ba5b7ce3ab86433f29c9fa3ced4ddd.jpg)
[intra group questions semester summary] some reference questions for beginners
Customer Stories | Netease spring breeze: the "spring breeze" of the fun industry, reaching out to all areas through in-depth interaction

GoF23—工厂模式

Selective Search for Object Recognition 论文笔记【图片目标分割】

Comparison between Prometheus and ZABBIX

Pychart cannot run designer Exe (this application failed to start because no Qt platform plugin could be I appears)

Logstash - logstash pushes data to redis

技术Leader的思考技巧
随机推荐
Multi thread synchronous downloading of network pictures
University Information Management System
数据可视化实战:实验报告
numpy. log
Logstash - logstash pushes data to redis
Work accumulation - problems encountered in using ThreadLocal in web requests
Pychart cannot run designer Exe (this application failed to start because no Qt platform plugin could be I appears)
Comparison between Prometheus and ZABBIX
Redis underlying data structure
【Spark】Spark SQL 字段血缘如何实现
Redis底层数据结构
Cython入门
Zotero使用之自定义参考文献格式
打印数字的位信息
Handwritten background management framework template (I)
Architecture design method
TCP连接与断开,状态迁移图详解
Web components series (10) -- realize the basic layout of mycard
成水最多的容器
NPM private server problem of peanut shell intranet penetration mapping