123456789101112131415161718192021 |
- let a: number;
- a = 4;
- function sum(a: number,b: number): number{
- return a + b;
- }
- let x: number = 1;
- let y = false;
- // &表示同时
- let j: {name: string} & {age: number};
- j = {name: 'ddd',age: 33};
- let n: number | boolean;
- // 类型别名
- let k: 1 | 2 | 3;
- type myType = 1 | 2 | 3;
- let m: myType;
|