Description
I'm trying out the new TypeScript support. But I can't add public
or private
to a method
Environment
System:
OS: macOS High Sierra 10.13.5
CPU: x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Binaries:
Node: 10.4.1 - ~/.nvm/versions/node/v10.4.1/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.1.0 - ~/.nvm/versions/node/v10.4.1/bin/npm
Browsers:
Chrome: 70.0.3538.77
Safari: 11.1.1
npmPackages:
@types/react: ^16.4.18 => 16.4.18
@types/react-dom: ^16.0.9 => 16.0.9
react: ^16.6.0 => 16.6.0
react-dom: ^16.6.0 => 16.6.0
react-scripts: 2.0.5 => 2.0.5
npmGlobalPackages:
create-react-app: 2.0.4
Steps to Reproduce
Since typescript support is not yet released to npm I followed @brunolemos steps to clone CRA and link react-scripts
. Then:
create-react-app cra-ts-test
cd cra-ts-test
yarn add typescript @types/react @types/react-dom @types/jest
yarn link react-scripts
- rename
index.js
toindex.tsx
- rename
App.js
toApp.tsx
- In
App.tsx
addedpublic
in front ofrender() {
yarn start
Expected Behavior
It should compile and work
Actual Behavior
Failed to compile
./src/App.tsx
SyntaxError: /Users/mikel/Projects/Lab/cra-ts-test/src/App.tsx: Unexpected token (6:9)
4 |
5 | class App extends Component {
> 6 | public render() {
| ^
7 | return (
8 | <div className="App">
9 | <header className="App-header">
Reproducible Demo
https://github.com/MikelArnaiz/cra-ts-test
(make sure to yarn link react-scripts
to the latest version with TS support)