Siobhan Holubicka
Siobhan Holubicka

Reputation: 157

Angular CLI Migrated to integrated Nx Monorepo getting several type mismatch errors (error TS2322)

I recently moved my Angular CLI to NX workspace monorepo and after fixing all the import errors, it compiled and works as before. However I have over 100 type error, and I have tried to fix individually but it seems to be creating more issues. Here are some examples:

'myvariable' is possibly 'null'.
Type 'null' is not assignable to type 'IMyInterface'.
Type 'string | null' is not assignable to type 'string'.
Type 'null' is not assignable to type 'SafeHtml'.
Type 'Observable<(myType| null)[]>' is not assignable to type 'Observable<myType[]>'.
Type 'MatTableDataSource<T, MatTableDataSourcePaginator>' is not assignable to type 'MatTableDataSource<never, MatTableDataSourcePaginator>'.
Type 'T[]' is not assignable to type 'never[]'.
Type 'T' is not assignable to type 'never'.
Type 'any' is not assignable to type 'never'.

Nearly every .ts file gives me an error in regards to type. I have tried turning off strict

tsconfig.app.json

{
 "extends": "../../tsconfig.base.json",
  "compilerOptions": {
   "outDir": "../../dist/out-tsc"
 },
  "files": ["src/main.ts", "src/polyfills.ts"],
  "include": ["src/**/*.d.ts"]
}

tsconfig.base.json

{
 "compileOnSave": false,
 "compilerOptions": {
 "baseUrl": ".",
 "outDir": "./dist/out-tsc",
 "forceConsistentCasingInFileNames": false,
 "strict": false,
 "noImplicitOverride": true,
 "noImplicitUseStrict": true,
 "noPropertyAccessFromIndexSignature": true,
 "noImplicitReturns": false,
"noFallthroughCasesInSwitch": false,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"noImplicitAny": false,
"strictNullChecks": false,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022",
"useDefineForClassFields": false,
"lib": ["ES2022", "dom"],
"esModuleInterop": true,
"paths": {
  "@app/environment": ["src/environments/environment.ts"],
  "@app/state": ["src/app/state/index"],
  "@app/state/*": ["src/app/state/*"],
  "crypto": ["node_modules/crypto-browserify"],
  "stream": ["node_modules/stream-browserify"],
  "util": ["node_modules/node-util"]
},
"rootDir": "."
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": false,
"strictInputAccessModifiers": false,
"strictTemplates": false
},
"exclude": ["node_modules", "tmp"],
"include": ["src/**/*.d.ts"],
"files": ["src/main.ts", "src/polyfills.ts"],
"types": ["jest"]
}

Has anyone had this issue before? It is a big project so I cannot include all the code. Is there a way to fix this issue for all or do I have to take each error and fix individually?

Upvotes: 0

Views: 42

Answers (0)

Related Questions