Object.keys Element implicitly has an 'any' type because expression of type 'string' can't be used to index type ts(7053)

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ cityid: string; sellerid: number; shopid: string; lat: number; lng: number; categoryid: string; pickself: string; page: number; }'.
No index signature with a parameter of type 'string' was found on type '{ cityid: string; sellerid: number; shopid: string; lat: number; lng: number; categoryid: string; pickself: string; page: number; }'.ts(7053)

解决方案

interface Params {
    cityid: string,
    sellerid: number,
    shopid: string,
    lat: number,
    lng: number,
    categoryid: string,
    pickself: string,
    page: number
}

type K = keyof typeof params;

Object.keys(params).forEach((key) => {
    if (params[key as K] === undefined) {
        delete params[key as K]
    }
})