diff --git a/packages/react/src/generators/application/application.spec.ts b/packages/react/src/generators/application/application.spec.ts index b25be440359fc..20e6ee1c45326 100644 --- a/packages/react/src/generators/application/application.spec.ts +++ b/packages/react/src/generators/application/application.spec.ts @@ -64,6 +64,8 @@ describe('app', () => { 'vite/client', 'node', 'vitest', + '@nx/react/typings/cssmodule.d.ts', + '@nx/react/typings/image.d.ts', ]); }); diff --git a/packages/react/src/generators/application/lib/update-jest-config.ts b/packages/react/src/generators/application/lib/update-jest-config.ts index cfb8c37877e83..3af0f138a5ff8 100644 --- a/packages/react/src/generators/application/lib/update-jest-config.ts +++ b/packages/react/src/generators/application/lib/update-jest-config.ts @@ -8,15 +8,17 @@ export function updateSpecConfig(host: Tree, options: NormalizedSchema) { } updateJson(host, `${options.appProjectRoot}/tsconfig.spec.json`, (json) => { - json.types = json.types || []; + const compilerOptions = json.compilerOptions ?? {}; + const types = compilerOptions.types ?? []; if (options.style === 'styled-jsx') { - json.types.push('@nx/react/typings/styled-jsx.d.ts'); + types.push('@nx/react/typings/styled-jsx.d.ts'); } - json.types = [ - ...json.types, + types.push( '@nx/react/typings/cssmodule.d.ts', - '@nx/react/typings/image.d.ts', - ]; + '@nx/react/typings/image.d.ts' + ); + compilerOptions.types = types; + json.compilerOptions = compilerOptions; return json; });