rollup打包报错“semantic error TS2802”

rollup版本:2.79.1;nodejs:16.16.0;typescript:5.1.6

错误信息

Error: D:/**/*.ts(158,32): semantic error TS2802: Type 'StyleSheetList' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.

修改tsconfig.json配置,增加"lib": ["es2015"]配置

{
  "files": [],
  "references": [
    {
      "path": "./tsconfig.node.json"
    },
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.vitest.json"
    }
  ],
  "compilerOptions": {
    "downlevelIteration": true,
    "lib": ["es2015"],
  }
}

源代码可参考:vue3-print-ts (gitee.com)

你可能感兴趣的:(前端,前端,javascript,rollup,typescript)