// TypeScript React /** @author Willy * @url https://reactjs.org/ **/ importReact from'react'; import{ PhotoStory,VideoStory } from'./stories'; functionStory(props) { constSpecificStory =components[props.]; return story={props.}attr2="&ref;"attr3="Hello\n"/>; } function attr1={function<noTag/>returnclassvar0x123{ } &noRef;hello() React.Component() }attr2="&ref;"> /* no comment*/ function return class var 0x123 &ref; hello() React.Component() . anyWord {function<tag>returnclassvar0x123hello() React.Component() } Tag$> /*comment*/attr1/*comment*/=/*comment*/"value"/*comment*/attr2/*comment*/attr3='a'key/*comment*/key2/> // Detect Valid tags /* comment */ { /* comment *//> word <noTag/>.<noTag/> } <noTag/> return /* comment multiline *//* comment */ && /*comment*/ &/*comment*/<noTag/> { Hello } ?/>; [ /> ( /> ,= &&|| return ; default; return anyWord<noTag> anyWord/*comment*/<noTag/> .<noTag> &<notag>|<noTag/> %/* comment*/<noTag/> // TODO: Fix this (comment before the tag name): varx =</**/div>div>; // Tag after ":" annotation: annotation:text [ ] console.("hello") // Type assertion in tag <number>/> <number>> /> // Non-ASCII tag name & attribute <日本語>日本語>; 本本:本-本aa本:本aa:aa/> /> />; {...x }y ={2}z/>; letk1 = a={10}b="hi"{...o}> hi hi hi! ; letk2 = a={10}b="hi">
My Div
{(name:string) =>
My name {name}
} ; letk3 = initialValues={{ x:"y"}}nextValues={a =>({ x:a.})}/>;// No Error // OK letk1 = a={10}b="hi"><>>; letk2 = a={10}b="hi"><>; letk3 = a={10}b="hi"><>; letk4 = a={10}b="hi"><>; // OK letk1 =
Hello world
; letk2 =
Hello {(user:any) => {user.}}
; letk3 =
{1}{"That is a number"}
; letk4 = Hello ; // Empty tags hello<> hello<string> <>>;// no whitespace < > >;// lots of whitespace </*starting wrap*/>/*ending wrap*/>;// comments in the tags <>hi>;// text inside <>hi
bye
>;// children <>1<>2.12.2>3>;// nested fragments <>#>;// # would cause scanning error if not in jsxtext // Tags after substitutions in templates
`aaa${//comment /*comment*/}` // Don't highlight tags within type declaration typeT12 =ReturnType<(<T>() =>T)>; typeT13 =ReturnType<(<T extendsU,U extendsnumber[]>() =>T)>; typeT14 =ReturnType<typeoff1>; typeT15 =ReturnType<(s:string) =>void>; // Don't highlight tags within variable declaration let myIdentity:<T>(arg:T) =>T <noTag/>= />; var myIdentity:<U>(arg:U) =>U =identity; const myIdentity:{<T>(arg:T):T}=identity; // Don't highlight tags within interfaces and classes interfaceGenericIdentityFn { <T>(arg:T):T; <noTag /> } classHandler { info:<T>(arg:T):T <noTag />; } // Highlight " // (the "cast" expression works and isn't supported in the TSX file) constgoodHighlighting = <T extendsI>( arg:T ) => { consta =arg returna } text extendsI/>// Here "" is a tag // Check character after tag name, do not highlight invalid tags <noTag ? <noTag , <noTag /* comment */? <noTag# <noTag/*comment*/# // Conditionals expressions lety =foo ==null?null:; letx =(foo ===null||foo ===undefined) ? undefined:hello; // Tagged template literals tagFunc`
Hello world! ${/>;22+"11"}`; obj..tagFunc`Setting ${setting} is ${value}!`;