以下代码引发错误。不知道为什么。
export enum ScreenSize {
XS_MOBILE = 'XS_MOBILE',
MOBILE = 'MOBILE',
TABLET_PORTRAIT = 'TABLET_PORTRAIT',
DESKTOP = 'DESKTOP',
TABLET_LANDSCAPE = 'TABLET_LANDSCAPE',
SS_DESKTOP = 'SS_DESKTOP',
}
export type SizingMap = { [key in ScreenSize]?: number };
const map:SizingMap = { DESKTOP: 3 }
const size = 'DESKTOP';
// ERROR: Element implicitly has an 'any' type because type 'SizingMap' has no index signature.ts(7017)
if(map[size]) { .... }