nx/packages/nest/src/generators/library/lib/update-tsconfig.ts
2023-04-18 12:47:02 -06:00

24 lines
753 B
TypeScript

import type { Tree } from '@nx/devkit';
import { readProjectConfiguration, updateJson } from '@nx/devkit';
import type { NormalizedOptions } from '../schema';
export function updateTsConfig(tree: Tree, options: NormalizedOptions): void {
const project = readProjectConfiguration(tree, options.projectName);
return updateJson(tree, `${project.root}/tsconfig.lib.json`, (json) => {
json.compilerOptions.target = options.target;
if (options.strict) {
json.compilerOptions = {
...json.compilerOptions,
strictNullChecks: true,
noImplicitAny: true,
strictBindCallApply: true,
forceConsistentCasingInFileNames: true,
noFallthroughCasesInSwitch: true,
};
}
return json;
});
}