简体   繁体   English

大型 SPA 前端中的静态与动态类型检查?

[英]Static vs dynamic type-checking in a large SPA frontend?

If I want to use static type-checking, I need to choose some of the existing solutions like Flow or TypeScript.如果我想使用静态类型检查,我需要选择一些现有的解决方案,比如 Flow 或 TypeScript。 Then I need to align my code to the offered rules.然后我需要将我的代码与提供的规则对齐。 The advantage is I have instant error highlights in the IDE, fail quick and early, as well as these are powerful and mature tools.优点是我在 IDE 中有即时错误高亮显示,快速和早期失败,而且这些都是强大而成熟的工具。

If I want to do dynamic checking, I need to build my own tools that will run inside the app on each method call where I need to be sure it receives correct input parameters.如果我想进行动态检查,我需要构建我自己的工具,这些工具将在每个方法调用时在应用程序内运行,我需要确保它接收到正确的输入参数。 The advantage is that I have full control on my code and I don't have to follow the others' rules if I don't like them.优点是我可以完全控制我的代码,如果我不喜欢其他人的规则,我就不必遵守他们的规则。 The disadvantage is it can be time-consuming to develop and test it and slow in action, as well as I can make conceptual mistakes that will force me to spend time not on the logic of the app but on improving my home-grown schema-checker system.缺点是开发和测试它可能很耗时,而且动作缓慢,而且我可能会犯概念性错误,这将迫使我把时间花在改进我自己的架构上而不是应用程序的逻辑上——检查器系统。

Which approach should I use if I plan that the app will be developed by a team and have a long lifecycle?如果我计划该应用程序将由团队开发并且具有很长的生命周期,我应该使用哪种方法?

Which approach should I use if I plan that the app will be developed by a team and have a long lifecycle?如果我计划该应用程序将由团队开发并且具有很长的生命周期,我应该使用哪种方法?

A lot goes into creating tools.很多东西都涉及到创建工具。 I'm personally leveraging all the effort already put in by the TypeScript team into creating something that exposes its full power in the form of alm IDE.我个人正在利用 TypeScript 团队已经投入的所有努力来创建一些以alm IDE 的形式展现其全部功能的东西。

Where you draw the line between using whats there and creating something new is your choice.在使用现有内容和创造新事物之间划清界限是您的选择。 I just like the consolidation and went full in with TypeScript.我只是喜欢整合并完全使用 TypeScript。

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

相关问题 类型检查运算符语句的结果 - Type-checking the result of operator statements Javascript:确保参数产生有效的HTML元素(类型检查) - Javascript: Ensuring an argument yields a valid HTML element (type-checking) 将流类型检查添加到grunt服务器开发工作流 - Adding flow type-checking to grunt server development workflow 在返回的对象中类型检查正确的键值使用 - Type-checking correct key-value usage in a returned object 前端模板化网站是动态的还是静态的? - Are frontend templated websites dynamic or static? 如何将方法添加到分配给变量c的对象常量中,以便满足类型检查? - How to add methods to the object literal being assigned to the variable c, so that the type-checking is satisfied? TypeScript 在使用它进行类型检查时出错 JavaScript 代码包含 React 组件 - TypeScript errors while using it for type-checking JavaScript code containing React components 如果JS包装器对象被认为是不良样式,是否使用lodash _.isString等进行类型检查也被视为不良样式? - if JS wrapper objects are considered bad style, is type-checking with lodash _.isString etc. considered bad style as well? 流-静态类型检查失败 - Flow - static type checking failing 静态与动态SVG - Static vs. Dynamic SVG
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM