为什么我的对象解构在打字稿中抛出无字符串索引签名错误?

Why is my object desctructoring throwing a no string index signature error in typescript?

给定一个对象

const appConfig: {
    brands: {...},
    market: {...},
}

我尝试通过打字稿解构它:

const {brand} =  appConfig.brand;

失败通过:

src/partner/transform.ts(17,12): error TS2459: Type 'IBrandConfig' has no property 'brand' and no string index signature.

这是一个错误的对象析构函数语法。这些将按预期工作:

const {brand} =  appConfig;
const {brand, market} =  appConfig;

因为它们是以下内容的快捷方式:

const brand =  appConfig.brand;
const market =  appConfig.market;