We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
根据目前的规则, Typescript的namespace是被推荐禁用的
eslint-config/typescript/index.js
Line 60 in 6ce40ed
个人对于namespace钟爱有加, 下面试举一例
export class Person { gender: Person.gender; } export namespace Person { export type gender = 'male' | 'female'; }
可以看出将类型挂载在class上令整体代码更加面向对象,更加利于理解, 外部引用也更加自然
import {Person} from './Person'; const myGender: Person.gender = 'male';
另外Typescript Deep Dive中Enum with static functions也是很好的一个例子。感觉很赞
此外,使用使用namespace替换传统的export对象字面量,感觉也挺香的
故此,是否我们的规则应该放开对于namespace的使用呢?如果认可将PR进行一定调整~
The text was updated successfully, but these errors were encountered:
我不建议开放namespace。模块化地管理类型更合适,如果类型多,可以import * as T from './some-module';这样子用
import * as T from './some-module';
如果开放命名空间,滥用的可能性会大于正确、合适地使用。因此如果实在需要命名空间,用注释禁一下就好了
Sorry, something went wrong.
有道理, 目前非tsc自身,其他编译器,尤其是swc, 在面对namespace的时候都时常出点问题
No branches or pull requests
根据目前的规则, Typescript的namespace是被推荐禁用的
eslint-config/typescript/index.js
Line 60 in 6ce40ed
个人对于namespace钟爱有加, 下面试举一例
可以看出将类型挂载在class上令整体代码更加面向对象,更加利于理解, 外部引用也更加自然
另外Typescript Deep Dive中Enum with static functions也是很好的一个例子。感觉很赞
此外,使用使用namespace替换传统的export对象字面量,感觉也挺香的
故此,是否我们的规则应该放开对于namespace的使用呢?如果认可将PR进行一定调整~
The text was updated successfully, but these errors were encountered: