├── src
│ ├── App.tsx
├── components
│ ├── Hello.tsx
├── styles
│ ├── index.css
├── index.html
├── package.json
└── tsconfig.json
Last active
October 9, 2020 16:33
-
-
Save frankievalentine/82d0076cd7dae78ea841641b15a17e5f to your computer and use it in GitHub Desktop.
react-typescript-parcel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import { render } from "react-dom"; | |
import { Hello } from "./Hello"; | |
// import './styles/index.css' | |
const App = () => { | |
return ( | |
<div> | |
{/* make sure Typescript is working by using number type */} | |
<Hello compiler="Parcel" framework={123} /> | |
</div> | |
); | |
}; | |
render(<App />, document.getElementById("app")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir [dirname] | |
cd [dirname] | |
yarn init | |
git init | |
touch index.html .gitignore tsconfig.json .README | |
echo -e "node_modules\nyarn.lock" >> .gitignore | |
mkdir src && cd src && touch App.tsx && mkdir Components && cd Components && touch Hello.tsx | |
code . | |
# add code to files from gist | |
cd ../.. | |
yarn add react react-dom --save | |
yarn add parcel-bundler typescript @types/react @types/react-dom --save-dev | |
tsc --init | |
# add to tsconfig.json from template in gist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
export interface HelloProps { | |
compiler: string; | |
framework: string; | |
} | |
export class Hello extends React.Component<HelloProps, {}> { | |
render() { | |
return ( | |
<h1> | |
Hello from {this.props.compiler} and {this.props.framework}! | |
</h1> | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>react-typescript-parcel</title> | |
</head> | |
<body> | |
<div id="app"></div> | |
<script src="./index.tsx"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"start": "parcel src/index.html", | |
"build": "parcel build src/index.html" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
// assuming your ts sources are in ./src/ | |
{ | |
"compilerOptions": { | |
"jsx": "react", | |
"target": "es6", | |
"module": "commonjs", | |
"strict": true, | |
"baseUrl": "./src", | |
"paths": { | |
"~*": ["./*"] | |
}, | |
}, | |
"include": ["src/**/*"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment