Last active
December 7, 2018 16:19
-
-
Save magic-akari/aa10dfb809268eb4f63d5749d113a93a to your computer and use it in GitHub Desktop.
tsc bug demo
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
export class App extends React.Component { | |
readonly state = { clicked: 0 }; | |
onClick = () => this.setState({ clicked: this.state.clicked + 1 }); | |
public render() { | |
return ( | |
<div> | |
<div>You have clicked {this.state.clicked}</div> | |
<button onClick={this.onClick}>click me</button> | |
</div> | |
); | |
} | |
} |
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
declare global { | |
const React: typeof import("react"); | |
const ReactDOM: typeof import("react-dom"); | |
} | |
export {}; |
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" /> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
<title>demo</title> | |
</head> | |
<body> | |
<div class="app"></div> | |
<script | |
src="https://cdn.jsdelivr.net/npm/[email protected]/umd/react.production.min.js" | |
integrity="sha256-JBRLQT7aJ4mVO0H2HRhGghv/K76c5WzE57wW0Flc6ZY=" | |
crossorigin="anonymous" | |
></script> | |
<script | |
src="https://cdn.jsdelivr.net/npm/[email protected]/umd/react-dom.production.min.js" | |
integrity="sha256-r3C7TtdCy1+TrjcCfRt8JYhwjH3zaYHxHhvSBj8WfrE=" | |
crossorigin="anonymous" | |
></script> | |
<script src="./index.js" type="module"></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
import { App } from "./app.js"; | |
ReactDOM.render(React.createElement(App, null), document.querySelector(".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
{ | |
"name": "test", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"private": true, | |
"scripts": { | |
"start": "tsc" | |
}, | |
"devDependencies": { | |
"@types/react": "^16.7.10", | |
"@types/react-dom": "^16.0.11", | |
"typescript": "^3.2.1" | |
}, | |
"dependencies": { | |
"react": "^16.6.3", | |
"react-dom": "^16.6.3" | |
} | |
} |
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
{ | |
"compilerOptions": { | |
"target": "es2018", | |
"module": "esnext", | |
"jsx": "react", | |
"strict": true, | |
"moduleResolution": "node", | |
"esModuleInterop": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment