typescript,使用ES6进行单文件编译:

tsc --target es6 test.ts

Cannot find name ‘Map’. Do you need to change your target library:
需要使用ES6编译

编译多个ts时,需要
–out xxx.js
指定编译后输出的文件

Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns
–module commonjs

replace(/-/g, “/”) :全局替换

2.Array和Map相关操作

var id=0;
var xx=Array.from({ length: 5 }).map(item => ({
value: ++id,
name: 'user'+id
}));
console.log(xx);

typescript: 基础知识整理_ide