typescript 发表于 2020-09-17 | 分类于 coding 命令安装1npm install -g typescript 编译为js12tsc hello.ts //不指定名字的话生成hello.jstsc hello.ts -w //使用watch mode 基本类型Number Boolean String Symbol1234567891011121314let num = 1; //不能num = "1" 已经规定了是number类型let is = true;let name = "name;let count: number = 10;let isDone: boolean = false;let name: string = "semliker";const sym = Symbol();let obj = { [sym]: "semlinker",};console.log(obj[sym]); // semlinker Array Object123456789101112131415let arr = [1,2,3] //不能arr[0] = 'a'或者arr.push('a') let list: number[] = [1, 2, 3];let netja = { name: 'aaa', age: 0}//不能添加属性,比如netja.skills = ['x'],或者给不符合属性类型的值,比如netja.name = 1//可以重新赋值netja = { name: 'xxx', age: 9}