简体   繁体   English

是否可以将React与Typescript一起使用而无需转译

[英]Is it possible to use React together with typescript without transpiling

Is it possible to use React together wit TypeScript in a simple way? 是否可以以简单的方式与TypeScript一起使用React

I want to write my components in TypeScript to have type-safety. 我想用TypeScript编写组件以具有类型安全性。 The few tutorials I've found so far do always need to have babel-loader, ts-loader and webpack running to make it work. 到目前为止,我发现的一些教程始终需要运行babel-loader,ts-loader和webpack才能使其正常运行。 In my tsconfig I can set "jsx" to either ("preserve","react" or "react-native") but I don't see how to go on from there or which one I should use. 在我的tsconfig中,我可以将“ jsx”设置为(“ preserve”,“ react”或“ react-native”),但是我不知道如何从那里继续或应该使用哪一个。

At the end I would like to have a jsx-file which I can reference from my cshtml <script src="@Url.Content("~/Scripts/TypeScript/MyComponent.jsx")" . 最后,我希望有一个jsx文件,可以从我的cshtml <script src="@Url.Content("~/Scripts/TypeScript/MyComponent.jsx")"引用。

If you want to use the full features of ES6, then the answer is NO. 如果您想使用ES6的全部功能,那么答案是否定的。 It'll be high time since most of the users upgrade their system so that all ES6/Typescript code runs properly. 由于大多数用户都将升级他们的系统,以便所有ES6 / Typescript代码正常运行,这将是时候了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM