当前位置:网站首页>typescript的type
typescript的type
2022-06-26 06:13: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}边栏推荐
- numpy.exp()
- MySQL-07
- 事务与消息语义
- Five solutions across domains
- 数据可视化实战:数据可视化
- Logstash——使用throttle过滤器向钉钉发送预警消息
- Tortoise and rabbit race example
- Spark source code analysis (I): RDD collection data - partition data allocation
- Summary of JVM interview focus (II) -- garbage collector (GC) and memory allocation strategy
- Selective search for object recognition paper notes [image object segmentation]
猜你喜欢

Logstash——使用throttle过滤器向钉钉发送预警消息

Efk upgrade to Clickhouse log storage practice

Zotero文献管理工具之Jasminum(茉莉花)插件

Logstash -- send an alert message to the nail using the throttle filter

EFK昇級到ClickHouse的日志存儲實戰

How to design a good technical scheme

MySQL-09

University Information Management System

Architecture design method

MySQL-07
随机推荐
Func < T, tresult > Commission - learning record
numpy. log
Thinking and summary of technical ability
MySQL-07
Gof23 - prototype mode
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications
在web页面播放rtsp流视频(webrtc)
Tortoise and rabbit race example
Message queuing - omnidirectional comparison
Typora activation method
架构设计方法
Introduction to canal deployment, principle and use
Message queue - message transaction management comparison
numpy.tile()
数据治理工作的几种推进套路
去哪儿网BI平台建设演进史
Redis underlying data structure
TCP连接与断开,状态迁移图详解
Cython入门