私は、TypeScript開発を少し新しくしましたが、かなり速くそれを把握することができました。 しかし私は、これらのモジュールローダ、コンパイラ、設定などすべてを含むプロジェクトをセットアップすることに不満を感じています。Visual StudioでReactを使用してTypeScriptをセットアップする方法
Visual Studio 2017でReactを使用してTypeScriptの作業環境をセットアップしようとしていますが、役に立たないです。私は、次の試してみた:
MyTestComponent.tsxを
/// <reference path="../typings/react/index.d.ts"/>
interface IProps {
name: string
}
class MyTestComponent extends React.Component<IProps, {}> {
render() {
console.log("rendering component");
return <span>{this.props.name}</span>;
}
}
App.ts
/// <reference path="TsImports.ts"/>
class App {
constructor() {
console.log("app started");
React.createElement(MyTestComponent,
{ name: "somename" },
document.getElementById("someid"));
}
}
index.htmlを
<div id="someid"></div>
<script src="~/Scripts/app.js"></script>
<script type="text/javascript">
var app = new App();
</script>
私はコンソールで "起動された"アプリケーションを取得していますが、レンダリングされた要素はありません。私はまた、コンソールエラーを取得しません。
私はVSコードでtypescriptウェブサイトから公式のチュートリアルを試してみました。しかし、私は全体のプロセスでWebpack
の役割は何かを理解することはできません。誰かがそれをどのように設定するか、または少なくとも私はいくつかのリソースを指摘するいくつかの詳細を説明してくださいか?ありがとう!