let bo:boolean=false
let un:undefined=undefined
let str:string='sa'
let num:number=12
let ar:Array<number>=[1,2]
let a:number[]=[12,21]
let text:string=`${str}`
let y:[string,number]
y=['12',12]
y[0]
y[1]=123
enum Color{red=1,green=2,blue=3}
let c:Color=Color.red
let na:string=Color[2]
let as:any=[1,'12'];
(function():void{

})();
(function():number{
return 1
})()
let obj:object=[1,2]
let ob:object=function(){}
interface deep{
name:string,
age:number,
job?:string
}
function admin(a:deep):object{
return a
}
admin({name:'123',age:12})
interface no{
readonly who:string
}
let p:no={who:'12'}

let r:number[]=[1,23,3]
let g:ReadonlyArray<number>=r

interface fn{
read(a:number):number
}
class Xa implements fn{
read(a:number):number{
return a
}
}
interface a{
str:string
}
interface Ta extends a{
num:number
}
let v=<Ta>{

}
v.str='12';
let n:Ta={str:'12',num:12};


class rr{
constructor(){

}
};

class Str extends rr{
static a:string='12';
constructor(){
super()
}
getName(a:string):string{
return a
}
but():void{
console.log(Str.a)
}
}
abstract class An{
abstract sp():void

};
function l(...q:number[]):void{
console.log(q[0])
}
l(1,2)
interface lk{
str:string,
arr:number[]
}
interface Par{
child:string
}
interface Tas extends Par{
str:string,
arr:number[],
cd:object,
get(this:Tas):()=>lk,
child:string
}
let asa:Tas={
str:'123',
arr:[1,2,3],
child:"123",
cd:{

},
get:function(this:Tas){
return ()=>{
return {str:this.str,arr:[123]}
}
}
}
interface len{
length:number
}
function lei<T extends len>(arg:T):T{
return arg;
}//T为任意类型变量 len为约束 不再是任意类型 需要符合条件
// 因为number不包含长度length属性
lei({length:12,value:'12'})
function Pro<T>(obj:T,key){
return obj[key]
}
let x={a:1}
Pro(x,"a")
class Las<T>{
s:T
}
let my=new Las<number>();

enum E{
a=12,
b='as',
c='fs',
d='a'
}//运行时JavaScript的对象 默认自增 或者自己初始化
;
let gg:number=E.a;
console.log(E[gg])
//兼容 赋值 如果两个对象存在至少一个相同属性可以赋值
//函数比较只要形参类型有一个相同 少的比多的 就会正确 而多比少则报错 因为多出来的参数找不到类型
let at:symbol=Symbol('123')
let gt:object={
[at]:12
}

2021-1-16更新学习

function fu(this:Window) {
console.log(this)
}
class Ass {
namea?:number
back:object=():void=>{}
readonly name: string = '12'
static age: number = 12
constructor (namea:number) {

}
}
Ass.age // 静态属性
const per = new Ass(12)
per.name // 只读
Gem.a // 枚举 把可能的情况列举出来
let as:number
let asa:unknown
asa = 123
asa = asa as number
let aaa:number = Gem.a
let j: {name:string} & {age:number}
j={
name:'12',
age:21
}
type myNum = 1|2
let sasa:myNum
sasa=2
type myString = string // 类型别名 可以简单数据类型 可以引用对象数据类型
interfance My {name:string}
// 接口与别名在限制对象属性一致 但接口可以限制class
type obj = {
name:string
}
let aaa:obj = {
name:'123'
}
let bbb:obj = {
name: '123'
}
let sa:myString = '21'
let h:[number,number]
h=[1,2]
aa(12,'12')
let a: object = [{a:1}]
enum Color {red=1,green,blue}
let d:Color = Color.red
interface obj{
a:1
}
function c(arg:obj | string):void{

}