Skip to content

Commit

Permalink
fix(react): types should be in compilerOptions of tsconfig.spec.json (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder authored Nov 16, 2023
1 parent 353bf0f commit 4bd4ec2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/react/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ describe('app', () => {
'vite/client',
'node',
'vitest',
'@nx/react/typings/cssmodule.d.ts',
'@nx/react/typings/image.d.ts',
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down

0 comments on commit 4bd4ec2

Please sign in to comment.