no-title

object generic

Array

Array

1
2
3
// 简写形式
const arr:string[] = ["foo"];
const arr1:Array<string> = ["foo"];

Read More

no-title

Normal Usage

1
2
3
4
5
6
7
class Greeter1 {
name: string; // init type
constructor(otherName: string) {
// receive init props value
this.name = otherName;
}
}

Read More

17tsconfigjson

ts配置支持 Tsc 命令行模式和tsconfig两种配置形式。

tsc 跟随npm install typescript 安装,tscconfig里支持更多配置项。

编译是有且只支持一种形式,

即 npx tsc xxx.ts 或者是 npx tsc.

Read More

type operator

keyof

The keyof operator takes an object type and produces a string or numeric literal union of its keys.

Read More

no-title

为啥需要类型擦除?

因为主流的执行器都是只支持 JavaScript,所以需要将 TypeScript 转为 JavaScript。

将ts 转成 js 的过程叫做类型擦除。

哪些方式做到

Read More

no-title

Read More

no-title

  • vscode 的鼠标报错

  • vscode 控制台输出

Read More

no-title

编程与类型系统

TypeScript 编程 - 基础,适合入门

类型和程序设计语言 - 早起,抽象,没用 TS 描述

TypeScript handbook

Read More

no-title

运行的环境 远端/本地

Read More

no-title

1
2
3
4
5
6
7
8
9
10
11
12
const d:Date = new Date();

const r:RegExp = /^ab/;

const m: Map<string, number> = new Map();

const wx: WeakMap<> = new WeakMap();

const s: Set = new Set();

const wx: WeakSet = new WeakSet();

Read More