[英]Typescript - const name already defined in type
I would like to use a TYPE that has the same name as the obj that I am declaring, but get the error FeatureFlags is already declared
- is this possible, or should I just change the name of the type declaration?我想使用与我声明的 obj 同名的 TYPE,但收到错误
FeatureFlags is already declared
- 这可能吗,还是应该只更改类型声明的名称?
export type FeatureFlags = {
[key: string]: {
name: string;
defaultValue: boolean;
};
};
export const FeatureFlags: FeatureFlags = {
SOME_FLAG: {
name: 'test-flag',
defaultValue: false,
},
};
Name-shadowing is a no-no, especially if you're wanting to export both variables from the same file. Name-shadowing 是一个禁忌,特别是如果您想从同一个文件中导出两个变量。 I usually stick to camelCase for consts and PascalCase for interfaces, classes and types.
我通常坚持使用camelCase 来表示const,而PascalCase 则表示接口、类和类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.