[英]How to use plain javascript react component in a typescript react project
One of my colleague used typescript for a frontend React project.我的一位同事将 typescript 用于前端 React 项目。 She is now leaving the company and management has assigned me into this project.
她现在要离开公司,管理层指派我参与这个项目。 They want me to deliver from Day 1, and they are ok with me using Javascript in the project.
他们希望我从第一天开始交付,他们同意我在项目中使用 Javascript。 So how can I use plain Javascript components in a Typescript React project.
那么我如何在 Typescript React 项目中使用普通的 Javascript 组件。 I understand the advantages of Typescript but right now I do not have time for learning it.
我了解 Typescript 的优点,但现在我没有时间学习它。 So any solutions to the problem would be great.
所以任何解决问题的方法都会很棒。
PS:附言:
I was not able to find any solutions for now我暂时找不到任何解决方案
Add allowJs: true
to the tsconfig file.添加
allowJs: true
到 tsconfig 文件。 This will allow you to import.js/.jsx files into.ts/.tsx Read more about option这将允许您将 .js/.jsx 文件导入 .ts/.tsx阅读更多关于选项
You can basically use Javascript in Typescript since TypeScript is a superset of JavaScript, just find the key differences in both languages (like: writing variables etc.) and you can start coding in Typescript. You can read more here to give you an overview of these differences您基本上可以在 Typescript 中使用 Javascript,因为 TypeScript 是 JavaScript 的超集,只需找到两种语言的主要区别(例如:编写变量等),您就可以在 Typescript 中开始编码。您可以在此处阅读更多内容以了解更多信息这些差异
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.