ES7 Object.entries() in TypeScript not working

前端 未结 4 2190
鱼传尺愫
鱼传尺愫 2020-12-01 20:39

I have an issue with transpiling ES7 code with TypeScript. This code:

const sizeByColor = {
    red: 100,
    green: 500,
};

for ( const [ color, size ] of          


        
4条回答
  •  再見小時候
    2020-12-01 21:32

    For a standalone Typescript app, I had to add the lib es2019.object to the tsconfig, and import the polyfill to make it work :)

    import 'core-js/es/object/from-entries';
    

提交回复
热议问题