{"record":{"id":"59544119c78aff5b","repo":"angular/angular-cli","slug":"failed-to-automatically-update-types-in-tsconfi","errorCode":null,"errorMessage":"Failed to automatically update types in \"${tsConfigPath}\". Please manually remove \"jasmine\" and add \"vitest/globals\" to compilerOptions.types.","messagePattern":"Failed to automatically update types in \"(.+?)\"\\. Please manually remove \"jasmine\" and add \"vitest/globals\" to compilerOptions\\.types\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/schematics/angular/migrations/migrate-karma-to-vitest/migration.ts","lineNumber":164,"sourceCode":"    if (tree.exists(tsConfigPath)) {\n      try {\n        const json = new JSONFile(tree, tsConfigPath);\n        const typesPath = ['compilerOptions', 'types'];\n        const existingTypes = (json.get(typesPath) as string[] | undefined) ?? [];\n        const newTypes = existingTypes.filter((t) => t !== 'jasmine');\n\n        if (!newTypes.includes('vitest/globals')) {\n          newTypes.push('vitest/globals');\n        }\n\n        if (\n          newTypes.length !== existingTypes.length ||\n          newTypes.some((t, i) => t !== existingTypes[i])\n        ) {\n          json.modify(typesPath, newTypes);\n        }\n      } catch (err) {\n        context.logger.warn(\n          `Failed to automatically update types in \"${tsConfigPath}\". ` +\n            `Please manually remove \"jasmine\" and add \"vitest/globals\" to compilerOptions.types.`,\n        );\n      }\n    }\n  }\n}\n\nfunction logSummary(\n  context: SchematicContext,\n  migratedProjects: string[],\n  skippedNonApplications: string[],\n  skippedMissingAppBuilder: string[],\n  manualMigrationFiles: string[],\n): void {\n  context.logger.info('\\n--- Karma to Vitest Migration Summary ---');\n  context.logger.info(`Projects migrated: ${migratedProjects.length}`);\n  if (migratedProjects.length > 0) {","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/migrations/migrate-karma-to-vitest/migration.ts#L146-L182","documentation":"The Karma-to-Vitest migration tries to rewrite compilerOptions.types in the project's tsconfig (remove \"jasmine\", add \"vitest/globals\") using a JSON editor. If editing fails (parse error, missing/odd tsconfig structure), it warns with manual instructions instead of failing the migration.","triggerScenarios":"`json.modify(typesPath, newTypes)` throws because the tsconfig file has JSON syntax errors (comments/trailing commas with strict parsing), is unreadable, or the types path cannot be created/modified in an unusual config layout.","commonSituations":"tsconfig extended/generated with unusual formats; hand-edited tsconfig with syntax errors; read-only files; a tsconfig whose compilerOptions.types is nested in an unexpected way.","solutions":["Open the reported tsConfigPath and manually remove \"jasmine\" and add \"vitest/globals\" to compilerOptions.types.","Fix JSON syntax errors in the tsconfig and re-run the migration.","Verify file write permissions on the tsconfig.","Ensure the tsconfig used by the test target is the one being edited (check extends chains)."],"exampleFix":"// before\nclass { \"compilerOptions\": { \"types\": [\"jasmine\"] } }\n// after\n\"compilerOptions\": { \"types\": [\"vitest/globals\"] }","handlingStrategy":"try-catch","validationCode":"let parsed; try { parsed = JSON.parse(stripComments(fs.readFileSync(tsConfigPath, 'utf8'))); } catch { console.warn(`${tsConfigPath} is not parseable — fix manually`); }","typeGuard":"function isTsConfigWithTypes(v: unknown): v is { compilerOptions?: { types?: string[] } } { return typeof v === 'object' && v !== null && 'compilerOptions' in v; }","tryCatchPattern":"try { json.modify(typesPath, newTypes); } catch { context.logger.warn(`Failed to automatically update types in \"${tsConfigPath}\". Please manually remove \"jasmine\" and add \"vitest/globals\".`); }","preventionTips":["Keep tsconfig files valid JSON(C) without exotic syntax.","Ensure compilerOptions.types exists explicitly in the tsconfig used by tests.","Don't make tsconfig read-only before running migrations.","Review extends chains so the right tsconfig is edited."],"tags":["tsconfig","migration","vitest","manual-intervention"],"backgroundTag":"tsconfig-edit-failed","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}