diff --git a/examples/typescript/compound.ts b/examples/typescript/compound.ts new file mode 100644 index 0000000..14846ab --- /dev/null +++ b/examples/typescript/compound.ts @@ -0,0 +1,51 @@ +// 复合 + +// let myVar: any = 1 + +// myVar = "" + +// myVar = true + +let myVar: string | number = 1 + +myVar = "" + +// myVar = false + +type ID = string | number + +let myID: ID = 1 + +myID = "" + + +interface Person { + name: string + age?: number +} + +let obj2: Person = { name: 'foo', age: 12 } + +obj2 = { name: 'bar' } + +let ns: number[] = [1, 2, 3]; + + +let person: [string, number, boolean] = ["Alice", 30, true]; + +enum Direction { + Up, + Down, + Left, + Right +} + +let direction: Direction = Direction.Up + + +enum Sizes { + Big, + Small +} + +let size: Sizes = Sizes.Big \ No newline at end of file