首页 > 解决方案 > 如何更改接口结构并重命名 VS Code 中的所有引用

问题描述

我有一个界面

interface IApplicationState {
    config: IConfig;
    lang: ILang;
    //many others
}

目前在许多地方使用,例如在带有connectfrom的类中react-redux,或在 reducers 方法中,例如:

const setLangReducer = (state: IApplicationState , { lang }: { lang: LangType }): IApplicationState  => ({
    ...state,
    lang: {
        currentLang: lang
    }
});

我想在根级别添加一些文件,并且所有现有的作为新属性的子级向下移动,例如:

interface IApplicationState {
    generalConfigs: {
        config: IConfig;
        lang: ILang;
    };
    externalConfig: {
        domain: string;         
    }
}

如果我手动进行更改,我将必须修复从根到config和的所有引用langgeneralConfigs.configgeneralConfigs.lang

也许有一些自动选项可以通过更改接口结构来更改所有引用?

标签: javascripttypescriptvisual-studio-code

解决方案


如果您想更改所有需要按 ctrl 的名称,然后按 3 次 R


推荐阅读