我正试图将一个遗留的(非常老式的Angular JS)项目从NPM切换到PNPM,并正在与打字错误作斗争.绝大多数是像这样的东西
error TS2339: Property 'mock' does not exist on type 'IAngularStatic'.
使用NPM,我得到了一份干净的Typescript 转载,我想保持这种方式.
我的tsfig.json是
{
"compilerOptions": {
"baseUrl": ".",
"module": "commonjs",
"target": "ES2017",
"sourceMap": true,
"inlineSources": true,
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
我试着把import "angular";import "angular-mocks";
和import "@types/angular";import "@types/angular-mocks";
相加,但得到了error TS2686: 'angular' refers to a UMD global, but the current file is a module. Consider adding an import instead.
我也try 了各种吊装方案,但有些随意,因为我对它没有太大的了解.
有谁能给我指个方向吗?
编辑:如果我这样做了,为了澄清
rm -rf node_modules
rm package-lock.json pnpm-lock.yaml npm-shrinkwrap.json
npm i --ignore-scripts
tsc
我没有得到错误(但这需要很长时间),而
rm -rf node_modules
rm package-lock.json pnpm-lock.yaml npm-shrinkwrap.json
pnpm i --ignore-scripts
tsc
相对较快地产生170个左右的TSC错误,其中绝大多数是TS2339错误.