mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-20 20:08:58 +00:00
Add TypeScriptReact syntax test file
This commit is contained in:
parent
768189859a
commit
76034880ae
35
tests/syntax-tests/highlighted/TypeScriptReact/app.tsx
Normal file
35
tests/syntax-tests/highlighted/TypeScriptReact/app.tsx
Normal file
@ -0,0 +1,35 @@
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;190;132;255m*[0m[38;2;248;248;242m [0m[38;2;249;38;114mas[0m[38;2;248;248;242m [0m[38;2;255;255;255mReact[0m[38;2;248;248;242m [0m[38;2;249;38;114mfrom[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mreact[0m[38;2;230;219;116m"[0m[38;2;248;248;242m;[0m
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;255;255;255mHelloComponent[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114mfrom[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m./hello[0m[38;2;230;219;116m"[0m[38;2;248;248;242m;[0m
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;255;255;255mNameEditComponent[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114mfrom[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m./nameEdit[0m[38;2;230;219;116m"[0m[38;2;248;248;242m;[0m
|
||||
|
||||
[38;2;249;38;114mexport[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;166;226;46mApp[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;255;255;255mname[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;255;255;255msetName[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mReact[0m[38;2;248;248;242m.[0m[38;2;166;226;46museState[0m[38;2;255;255;255m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mdefaultUserName[0m[38;2;230;219;116m"[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;255;255;255meditingName[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;255;255;255msetEditingName[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mReact[0m[38;2;248;248;242m.[0m[38;2;166;226;46museState[0m[38;2;255;255;255m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mdefaultUserName[0m[38;2;230;219;116m"[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m
|
||||
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;166;226;46mloadUsername[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239msetTimeout[0m[38;2;255;255;255m([0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46msetName[0m[38;2;255;255;255m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mname from async call[0m[38;2;230;219;116m"[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46msetEditingName[0m[38;2;255;255;255m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mname from async call[0m[38;2;230;219;116m"[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m500[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255mReact[0m[38;2;248;248;242m.[0m[38;2;166;226;46museEffect[0m[38;2;255;255;255m([0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46mloadUsername[0m[38;2;255;255;255m([0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;248;248;242m][0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m
|
||||
|
||||
[38;2;248;248;242m [0m[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;166;226;46msetUsernameState[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46msetName[0m[38;2;255;255;255m([0m[38;2;255;255;255meditingName[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;255;255;255m([0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[3;38;2;166;226;46mHelloComponent[0m[38;2;248;248;242m [0m[38;2;166;226;46muserName[0m[38;2;249;38;114m=[0m[38;2;248;248;242m{[0m[38;2;255;255;255mname[0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[3;38;2;166;226;46mNameEditComponent[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46minitialUserName[0m[38;2;249;38;114m=[0m[38;2;248;248;242m{[0m[38;2;255;255;255mname[0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46meditingName[0m[38;2;249;38;114m=[0m[38;2;248;248;242m{[0m[38;2;255;255;255meditingName[0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46monNameUpdated[0m[38;2;249;38;114m=[0m[38;2;248;248;242m{[0m[38;2;255;255;255msetUsernameState[0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46monEditingNameUpdated[0m[38;2;249;38;114m=[0m[38;2;248;248;242m{[0m[38;2;255;255;255msetEditingName[0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m</[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m
|
||||
[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m
|
25
tests/syntax-tests/source/TypeScriptReact/LICENSE.md
Normal file
25
tests/syntax-tests/source/TypeScriptReact/LICENSE.md
Normal file
@ -0,0 +1,25 @@
|
||||
The `app.tsx` file has been added from https://github.com/Lemoncode/react-typescript-samples under the following license:
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 brauliodiez
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
35
tests/syntax-tests/source/TypeScriptReact/app.tsx
Normal file
35
tests/syntax-tests/source/TypeScriptReact/app.tsx
Normal file
@ -0,0 +1,35 @@
|
||||
import * as React from "react";
|
||||
import { HelloComponent } from "./hello";
|
||||
import { NameEditComponent } from "./nameEdit";
|
||||
|
||||
export const App = () => {
|
||||
const [name, setName] = React.useState("defaultUserName");
|
||||
const [editingName, setEditingName] = React.useState("defaultUserName");
|
||||
|
||||
const loadUsername = () => {
|
||||
setTimeout(() => {
|
||||
setName("name from async call");
|
||||
setEditingName("name from async call");
|
||||
}, 500);
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
loadUsername();
|
||||
}, []);
|
||||
|
||||
const setUsernameState = () => {
|
||||
setName(editingName);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<HelloComponent userName={name} />
|
||||
<NameEditComponent
|
||||
initialUserName={name}
|
||||
editingName={editingName}
|
||||
onNameUpdated={setUsernameState}
|
||||
onEditingNameUpdated={setEditingName}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user