I have monorepo with lerna. in my project I have nodejs and angular.
Angular uses "typescript": "~3.5.3"
.
Nodejs have those packages to work with sequelize:
"@types/node": "^12.12.16",
"@types/validator": "^12.0.1",
"reflect-metadata": "^0.1.13",
"sequelize": "^5.21.2",
"sequelize-typescript": "^1.1.0"
The problem is I got error:
ERROR in [at-loader] ..\..\node_modules\sequelize\types\lib\transaction.d.ts:33:14
TS1086: An accessor cannot be declared in an ambient context.
According to stackoverflow answer I need to upgrade to 3.7.3. When I upgrade it works fine in nodejs sequelize side.
But when I change the typescript to 3.7.3 then angular doesn't work:
ERROR in The Angular Compiler requires TypeScript >=3.4.0 and <3.6.0 but 3.7.3 was found instead.
What can I do to fix this?
I can fix this error for you, but you should separate your projects because it's difficult to maintain a front-end and back-end monorepo. This won't be your last conflict of dependencies.
Angular 8.x is stuck on TypeScript 3.5, but everything I've read online says it will compile okay with the latest TypeScript 3.7, and Angular 9 is reportedly going to target 3.7 as well because of Ivy.
You have to disable enforcing of the TypeScript version by the Angular compiler:
tsconfig.json:
{
// ...
"angularCompilerOptions": {
// ...
"disableTypeScriptVersionCheck": true
}
}
That will get the project to compile, but you'll get a run-time error because Angular 8 doesn't define a default importer. We can fix this by adding one to the polyfills
polyfills.ts:
// @ts-ignore
window.__importDefault = function(mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Later when you upgrade to Angular 9. The above can be undone and it should compile with TypeScript 3.7