gpt4 book ai didi

typescript - TSLint 成员排序

转载 作者:行者123 更新时间:2023-12-03 18:40:56 33 4
gpt4 key购买 nike

我的 tslint.json 中有以下规则:

    "member-ordering": [
true,
{
"order": [
"public-before-private",
"static-before-instance",
"variables-before-functions"
]
}
],

但是我仍然收到此警告:
Warning: member-ordering - Bad member kind: public-before-private

Typescrypt 版本是 3.1.1

节点版本为 10.10.0

最佳答案

正如错误消息所说,tslint 无法识别您放入 order 数组中的值。阅读 documentation of the member-ordering rule 中的 member-ordering

您可以在 tslint.json 中指定您想要的确切顺序,或者您可以仅指定一些组件(例如,让静态方法退出)并且缺少的组件可以保留在类中的任何位置。

以下配置符合你表达的规则:

"member-ordering": [
true,
{
"order": [
"public-static-field",
"public-static-method",
"public-instance-field",
"public-constructor",
"public-instance-method",

"protected-static-field",
"protected-static-method",
"protected-instance-field",
"protected-constructor",
"protected-instance-method",

"private-static-field",
"private-static-method",
"private-instance-field",
"private-constructor",
"private-instance-method"
]
}
],

关于typescript - TSLint 成员排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52862355/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com