Microsoft/TypeScript
在 GitHub 查看Rename doesn't work on declaration whose name is a string literal
Open
#57,026 创建于 2024年1月11日
Domain: LS: RefactoringsExperience EnhancementHelp WantedSuggestion
仓库指标
- Star
- (48,455 star)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 9 个 PR)
描述
Follow up to https://github.com/microsoft/TypeScript/issues/56052, which was fixed by https://github.com/microsoft/TypeScript/pull/56061. That fix means that rename from string literal values that are contextually typed by the type of the string-literal-named property do work. But renames on the actual property declaration still don't.
interface I {
"Prop 1 Foo": string
// ^-- rename here doesn't work
}
declare const fn: <K extends keyof I>(p: K) => void
fn("Prop 1 Foo")
As before, if you use constant with a literal type, renaming the literal type does work:
declare const indirect: "Prop 1 Foo"
interface I {
[indirect]: string
}
// ... same as before ...