Etsy的TypeScript之旅

Over the past few years, Etsy’s Web Platform team has spent a lot of time bringing our frontend code up to date. It was only a year and a half ago that we modernized our Javascript build system in order to enable advanced features, things like arrow functions and classes, that have been added to the language since 2015. And while this upgrade meant that we had futureproofed our codebase and could write more idiomatic and scalable Javascript, we knew that we still had room for improvement.

在过去的几年里,Etsy的网络平台团队花了很多时间使我们的前端代码达到最新水平。只是在一年半前,我们才将我们的Javascript构建系统现代化,以便启用先进的功能,如箭头函数,这些功能自2015年以来已被添加到该语言中。虽然这次升级意味着我们的代码库已经面向未来,可以编写更多的成语和可扩展的Javascript,但我们知道,我们仍然有改进的空间。

Etsy has been around for over sixteen years. Naturally, our codebase has become quite large; our monorepo has over seventeen thousand JavaScript files in it, spanning many iterations of the site. It can be hard for a developer working in our codebase to know what parts are still considered best practice, and which parts follow legacy patterns or are considered technical debt. The JavaScript language itself complicates this sort of problem even further — in spite of the new syntax features added to the language over the past few years, JavaScript is very flexible and comes with few enforceable limitations on how it is used. This makes it notoriously challenging to write JavaScript without first researching the implementation details of any dependencies you use. While documentation can help alleviate this problem somewhat, it can only do so much to prevent a JavaScript library from being used improperly, which can ultimately lead to unreliable code.

Etsy已经有十六年的历史了。自然地,我们的代码库变得相当大;我们的monorepo有超过17000个JavaScript文件,跨越了网站的许多迭代。对于在我们的代码库中工作的开发者来说,很难知道哪些部分仍然被认为是最佳实践,哪些部分遵循传统模式或被认为是技术债务。JavaScript语言本身使这种问题更加复杂--尽管在过去的几年里为该语言添加了新的语法功能,但JavaScript非常灵活,对它的使用方式几乎没有可执行的限制。这使得在不首先研究你所使用的任何依赖关系的实现细节的情况下编写JavaScript成为众所周知的挑战。虽然文档可以在一定程度上帮助缓解这个问题,但它只能在很大程度上防止JavaScript库被不当使用,这最终会导致不可靠的代码。

All of these problems (and many more!) were ones that we felt TypeScript might be a...

开通本站会员,查看完整译文。

ホーム - Wiki
Copyright © 2011-2024 iteam. Current version is 2.129.0. UTC+08:00, 2024-07-04 01:34
浙ICP备14020137号-1 $お客様$