The difference is that as Circle
works in TSX files, but <Circle>
conflicts with JSX syntax. as
was introduced for this reason.
For example, the following code in a .tsx
file:
var circle = <Circle> createShape("circle");
Will result in the following error:
error TS17002: Expected corresponding JSX closing tag for 'Circle'.
However, as Circle
will work just fine.
Use as Circle
from now on. It's the recommended syntax.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…