Javascript 将proton native的记事本示例从js转换为tsx时出现问题
我尝试将记事本示例从proton本机转换为Typescript。我遇到了一些无法解决的问题 代码: TSConfig:Javascript 将proton native的记事本示例从js转换为tsx时出现问题,javascript,node.js,typescript,react-native,proton-native,Javascript,Node.js,Typescript,React Native,Proton Native,我尝试将记事本示例从proton本机转换为Typescript。我遇到了一些无法解决的问题 代码: TSConfig: { "compilerOptions": { "strict": true, "target": "es6", "module": "ES2015" } } { "name": "notepad", "ver
{
"compilerOptions": {
"strict": true,
"target": "es6",
"module": "ES2015"
}
}
{
"name": "notepad",
"version": "1.0.0",
"type": "module",
"description": "a notepad app built using proton-native",
"main": "index.tsx",
"scripts": {
"start": "babel-node index.tsx"
},
"dependencies": {
"@types/jest": "^26.0.22",
"@types/node": "^14.14.37",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"proton-native": "^2.0.0",
"typescript": "^4.2.4"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/node": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-0": "^7.0.0"
},
"author": "",
"license": "ISC"
}
package.json:
{
"compilerOptions": {
"strict": true,
"target": "es6",
"module": "ES2015"
}
}
{
"name": "notepad",
"version": "1.0.0",
"type": "module",
"description": "a notepad app built using proton-native",
"main": "index.tsx",
"scripts": {
"start": "babel-node index.tsx"
},
"dependencies": {
"@types/jest": "^26.0.22",
"@types/node": "^14.14.37",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"proton-native": "^2.0.0",
"typescript": "^4.2.4"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/node": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-0": "^7.0.0"
},
"author": "",
"license": "ISC"
}
index.tsx
import React, { Component } from 'react';
import fs from 'fs';
import { App, AppRegistry, Window, TextInput, View } from 'proton-native';
class Notepad extends Component {
state = { text: '' };
shouldComponentUpdate(nextProps, nextState) {
if (typeof nextState.text === 'string') return false;
// nextState is set from input
else return true; // nextState is set from file
}
render() {
return (
<App>
<Window>
<View style={{ flex: 1 }}>
<TextInput
onChangeText={text => this.setState({ text })}
value={this.state.text}
style={{ flex: 1 }}
multiline
/>
</View>
</Window>
</App>
);
}
}
AppRegistry.registerComponent('notepad', <Notepad />);
您可以检查如何设置tsconfig.json。我知道这是为React Native设计的,但它仍然会有帮助