== Why is this an issue?

Type assertion can be done in two ways: with ``++as MyType++`` or with ``++<MyType>++``. But since there is an ambiguity in the latter when using JSX and there is no ambiguity in the former, ``++as++`` is preferred.


=== Noncompliant code example

[source,javascript]
----
var foo = <any>"foo";  // Noncompliant
----


=== Compliant solution

[source,javascript]
----
var foo = "foo" as any;
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Use "as" type assertion here instead.


=== Highlighting

``++<foo>++``


'''
== Comments And Links
(visible only on this page)

=== on 31 Jul 2017, 18:17:37 Elena Vilchik wrote:
\[~ann.campbell.2] Ann, could you explain in more details why ``++<T>++`` notation is ambiguous?

=== on 31 Jul 2017, 19:40:12 Ann Campbell wrote:
\[~elena.vilchik] from \https://basarat.gitbooks.io/typescript/content/docs/types/type-assertion.html: 


____there is an ambiguity in the language grammar when using <foo> style assertions in JSX____


In trying to re-find my original reference (I didn't) I also came across https://stackoverflow.com/a/33503842/2662707[this SO answer], which states it slightly differently


____
The difference is that as Circle works in TSX files, but <Circle> conflicts with JSX syntax.

____

=== on 2 Aug 2017, 09:21:09 Elena Vilchik wrote:
\[~ann.campbell.2] I think we can say something like: 

``++But since the latter is ambiguous in language grammar when using JSX and the former ...++``



=== on 2 Aug 2017, 15:46:36 Ann Campbell wrote:
Updated [~elena.vilchik]. See what you think.

endif::env-github,rspecator-view[]
