我有两份文件,
App.tsx:个
const data = {games:{type: [], sport: [], category: []}}
以上是我收到的动态数据.
我需要将上述类型的key of datpe.Games设置为有效的类型,
type Valid = keyof typeof data.games
如果它是相同的文件,则不会像上面那样分配问题.
但我有单独的类型文件,比如,
Apptype.ts个
// How can I make the below keyof typeof [dynamicName] ?
export type Valid = keyof typeof data.games;
export interface IOption {
id: number;
value: string;
valid: Record<Valid, number[]>;
}
在上面的文件data.games
中抛出错误,因为在该文件中不会有这样的变量名.
那么,如何将动态值指定为keyof typeof [.....]
呢?
Working Example:个