Currently, I am facing a challenge in migrating an outdated Angular JS project from npm to pnpm. The main issue I am encountering is related to typescript errors, particularly the error message that states:
error TS2339: Property 'mock' does not exist on type 'IAngularStatic'
. With npm, the typescript transpile runs smoothly, and I aim to maintain this efficiency.
Here is a glimpse of my tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"module": "commonjs",
"target": "ES2017",
"sourceMap": true,
"inlineSources": true,
"allowSyntheticDefaultImports": true
},
"exclude":
[
"node_modules"
]
}
I have attempted to include
import "angular"; import "angular-mocks"
as well as import "@types/angular"; import "@types/angular-mocks"
, but it resulted in another error: error TS2686: 'angular' refers to a UMD global, but the current file is a module. Consider adding an import instead.
Additionally, I have experimented with different hoisting options, albeit somewhat haphazardly due to my limited understanding of it.
Any assistance or guidance in the right direction would be greatly appreciated.
Edit: Just for clarification, running the following commands,
rm -rf node_modules
rm package-lock.json pnpm-lock.yaml npm-shrinkwrap.json
npm i --ignore-scripts
tsc
produces no errors (although it is time-consuming); however, executing
rm -rf node_modules
rm package-lock.json pnpm-lock.yaml npm-shrinkwrap.json
pnpm i --ignore-scripts
tsc
quickly generates around 170 tsc errors, most of which are TS2339 errors.