Skip to content

Commit

Permalink
docs(examples/typescript): add compound
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree committed Mar 26, 2023
1 parent e6dd064 commit 6673af2
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions examples/typescript/compound.ts
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6673af2

Please sign in to comment.