简体   繁体   English

旧文件上的 javascript 到 typescript

[英]javascript to typescript on an old file

I have found a front-end application here: https://github.com/Clarvel/TennoTyper (the main.js file) and am wondering if I should read what he did and convert it to typescript.我在这里找到了一个前端应用程序: https://github.com/Clarvel/TennoTyper (main.js 文件),我想知道我是否应该阅读他所做的并将其转换为 typescript。 Right now I am just importing the javascript file into my scripts in angular.json and is causing a significant slowdown.现在我只是将 javascript 文件导入到我的脚本中 angular.json 并导致显着减速。 I wanted to use the code I found to make it into a back-end for my (and my friends) discord server to translate into the different languages of a game with a public API (which I will still need to research how to do but expressJS looks promising).我想使用我发现的代码将其作为我(和我的朋友)discord 服务器的后端,以使用公共 API 将其翻译成游戏的不同语言(我仍然需要研究如何做但是expressJS 看起来很有希望)。

Tl;dr: Importing JS file in Angular is causing slowdown (high image load count). Tl; dr:在 Angular 中导入 JS 文件会导致速度变慢(图像加载计数高)。 Should I convert this file to typescript or will this process take too long and be redundant.我应该将此文件转换为 typescript 还是此过程会花费太长时间并且是多余的。

Edit: Functionally the app wil work the same way, but it will return an image instead of having to type it in a box on the website.编辑:从功能上讲,该应用程序将以相同的方式工作,但它将返回图像,而不必在网站上的框中输入图像。

Transpiling a exact JavaScript file to Typescript won't help you.将精确的 JavaScript 文件转换为 Typescript 对您没有帮助。

Even you code your application in angular (means typescript)即使您在 angular (意味着打字稿)中编写您的应用程序

At the end of the day browser only understands javascript.最终浏览器只能理解 javascript。 Your code will be transpiled into javascript when you are building your pacakge.当你构建你的包时,你的代码将被编译成 javascript。

So find out root cause slowness in the script and fix.因此,找出脚本中运行缓慢的根本原因并进行修复。

If you are familiar with typescript, do it in that way.如果您熟悉 typescript,请按此方式操作。 Straight conversion without any improvement won't provide any impact.没有任何改进的直接转换不会产生任何影响。

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

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