Are ESLint rules around performance worth advocating?
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 20/100
- Issue 类型
- 文档
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- eslint, typescript
调研方向
阅读链接的 TypeScript wiki 性能页面,以及所引用的、建议优先使用 interfaces 和显式返回类型的 ESLint 规则。该 issue 要求 maintainer 指导是否应提倡这些规则,以及它们对性能的影响有多大;其中没有指出要修改的文件、测试或具体文档变更。
由索引模型根据 Issue 内容生成。
描述
Hey @DanielRosenwasser,
I do hope you're well. First up, this is not directly an issue with the wiki at all, but I thought this was a good place to have a conversation about your wiki page on performance.
I was just talking with @dragomirtitian about me writing a blog post which would show how to take a few of the tips in here and apply them with ESLint; there’s ESLint rules out there that can help with this. Essentially the main ones of interest are:
- Prefer Interface over Type https://github.com/cartant/eslint-plugin-etc/blob/main/docs/rules/prefer-interface.md
- Enforce return types https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md
Titian posed the (entirely helpful) question:
I'm sure these make difference.. By at what point.. 1K loc? 10Kloc? 100? If this is a concern for huge scale projects is it really worth it for smaller projects? I mean shaving off 0.2s in a build doesn't seem worth it if I have to maintain a type and an inferable return type.
This is a great question. And I have to state a personal stylistic preference fortypes over interfaces, as well as preferring return type inference. Much less noisy. But perf is royalty and style is secondary.
My own feeling is that if you want to go with these rules, it’s easier if you start with them at the beginning of a project that you expect to grow. As retro-fixing all of these in a codebase would not be fun!
Anyway, rambling done. I have two questions for you if have a moment:
-
Is it worth blogging to advocate that people use the above ESLint rules? Or is this potentially transient advice? Something that’s useful now but could change as the compiler evolves?
-
Do you have a feeling for what level of difference that following these standards can make? The answer will no doubt be "it depends", but I'm curious if you happen to have an idea for what the boundaries of success could look like here. So, is it possible to say something like "enforcing return types on functions has been observed to improve type checking performance by up to 40%", or "preferring
interfaces overtypes has been observed to improve type checking performance by up to 20%"? Actually having an idea of the level of difference that could be made is a super helpful piece of info. (Essentially this is Titian's question 😄 )
I hope you don't mind me posting the question here. I did consider DMing you instead, but I thought I'd do a @swyx and "learn in public" 😄
- 主要语言
- JavaScript
- 星标
- 759
- 派生
- 315
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/TypeScript-wiki 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 50/100
microsoft/TypeScript-wiki#327 ·
-
难度 5/5 一周以上 新手友好度 15/100
microsoft/TypeScript-wiki#323 ·
-
难度 2/5 1-3 小时 新手友好度 25/100
microsoft/TypeScript-wiki#307 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 35/100
microsoft/TypeScript-wiki#293 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 25/100
microsoft/TypeScript-wiki#260 · 2 条评论 ·
查看 microsoft/TypeScript-wiki 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
mksglu/context-mode#1200 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
neondatabase/website#5944 ·
-
module: core
难度 2/5 1-3 小时 新手友好度 75/100
bigbluebutton/bigbluebutton#25849 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
jaegertracing/jaeger-ui#4506 ·