package.json
{
"name": "tsc-tsx",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@types/react": "^17.0.3",
"typescript": "3.9.9"
}
}
tsconfig.json
{
"compilerOptions": {
"jsx": "react",
"target": "es6",
"module": "commonjs",
"strict": true,
}
}
index.tsx
function INode() {
return <div>xxx</div>;
}
"jsx": "react",
yarn tsc
生成 index.js
"use strict";
function INode() {
return React.createElement("div", null, "xxx");
}
"jsx": "react-native",
yarn tsc
生成index.js
"use strict";
function INode() {
return <div>xxx</div>;
}
"jsx": "preserve",
yarn tsc
生成 index.jsx
"use strict";
function INode() {
return <div>xxx</div>;
}
网友评论