TypeScript学习笔记

let myname:string= 'Helloworld';
console.log(myname)

let isDone:boolean = false;
let aihao:string[] = ['唱','跳','rap'];
let age:number = 18
if(age>=18){
    isDone = true
    console.log(isDone)
    console.log('成年了')
}else{
    console.log(isDone)
    console.log('未成年')
}

enum color{ BLUE,RED,GREEN,YELLOW} 
let colorn:color = color.GREEN

enum family {YEYE="grandpa",NAINAI="grandma",MAMA="mother",BABA ="father"}
let baba:family = family.BABA
console.log(baba)

enum Enum{A,B,C='fuck'}
console.log(Enum.C)

let test :any = 666
console.log(test)
warnUser()

function warnUser(): void {  console.log("This is my warning message");}

let n :null = null
console.log(n)
Output
"use strict";
let myname = 'Helloworld';
console.log(myname);
let isDone = false;
let aihao = ['唱', '跳', 'rap'];
let age = 18;
if (age >= 18) {
    isDone = true;
    console.log(isDone);
    console.log('成年了');
}
else {
    console.log(isDone);
    console.log('未成年');
}
var color;
(function (color) {
    color[color["BLUE"] = 0] = "BLUE";
    color[color["RED"] = 1] = "RED";
    color[color["GREEN"] = 2] = "GREEN";
    color[color["YELLOW"] = 3] = "YELLOW";
})(color || (color = {}));
let colorn = color.GREEN;
var family;
(function (family) {
    family["YEYE"] = "grandpa";
    family["NAINAI"] = "grandma";
    family["MAMA"] = "mother";
    family["BABA"] = "father";
})(family || (family = {}));
let baba = family.BABA;
console.log(baba);
var Enum;
(function (Enum) {
    Enum[Enum["A"] = 0] = "A";
    Enum[Enum["B"] = 1] = "B";
    Enum["C"] = "fuck";
})(Enum || (Enum = {}));
console.log(Enum.C);
let test = 666;
console.log(test);
warnUser();
function warnUser() { console.log("This is my warning message"); }
let n = null;
console.log(n);

Compiler Options
{
  "compilerOptions": {
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "declaration": true,
    "target": "ES2017",
    "jsx": "react",
    "module": "ESNext",
    "moduleResolution": "node"
  }
}

Playground Link: Provided

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值