ES7 Object.entries() in TypeScript not working

前端 未结 4 2179
鱼传尺愫
鱼传尺愫 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:15

    I can reproduce your problem when I have a global compiler but not local one in the ./node_modules.

    In my case compiler just does not know which tsconfig.json file to use. Pointing it to particular tsconfig.json file helps:

    tsc --project ./tsconfig.json

    I have also added dom option to the lib, because es2017 does not recognize console:

    "lib": [
        "es2017",
        "dom"
    ]
    

提交回复
热议问题