Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 501 Bytes

inline-angle-brackets.md

File metadata and controls

19 lines (13 loc) · 501 Bytes

Type assertions have two forms. One is the "angle-bracket" syntax:

let someValue: any = "this is a string"

let strLength: number = (<string>someValue).length

And the other is the as-syntax:

let someValue: any = "this is a string"

let strLength: number = (someValue as string).length

The two samples are equivalent. Using one over the other is mostly a choice of preference; however, when using TypeScript with JSX, only as-style assertions are allowed.