From 3bbd30bcb26aaa5b8cdd3d46e7f6504de617610d Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Thu, 20 Jul 2023 16:13:12 +0300 Subject: [PATCH] fix(storybook): make sure skipLibCheck is true closed #18153 --- .../generators/configuration/configuration.ts | 2 ++ .../configuration/lib/util-functions.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/storybook/src/generators/configuration/configuration.ts b/packages/storybook/src/generators/configuration/configuration.ts index b9824892ae6c9..d6d172f791684 100644 --- a/packages/storybook/src/generators/configuration/configuration.ts +++ b/packages/storybook/src/generators/configuration/configuration.ts @@ -23,6 +23,7 @@ import { configureTsSolutionConfig, createProjectStorybookDir, createStorybookTsconfigFile, + editTsconfigBaseJson, getE2EProjectName, getViteConfigFilePath, projectIsRootProjectInStandaloneWorkspace, @@ -128,6 +129,7 @@ export async function configurationGenerator( ); } configureTsProjectConfig(tree, schema); + editTsconfigBaseJson(tree); configureTsSolutionConfig(tree, schema); updateLintConfig(tree, schema); diff --git a/packages/storybook/src/generators/configuration/lib/util-functions.ts b/packages/storybook/src/generators/configuration/lib/util-functions.ts index 1ba51389ff470..f16d33bf379b2 100644 --- a/packages/storybook/src/generators/configuration/lib/util-functions.ts +++ b/packages/storybook/src/generators/configuration/lib/util-functions.ts @@ -28,6 +28,7 @@ import { import { StorybookConfigureSchema } from '../schema'; import { UiFramework7 } from '../../../utils/models'; import { nxVersion } from '../../../utils/versions'; +import ts = require('typescript'); const DEFAULT_PORT = 4400; @@ -259,6 +260,23 @@ export function createStorybookTsconfigFile( writeJson(tree, storybookTsConfigPath, storybookTsConfig); } +export function editTsconfigBaseJson(tree: Tree) { + let tsconfigBasePath = 'tsconfig.base.json'; + + // standalone workspace maybe + if (!tree.exists(tsconfigBasePath)) tsconfigBasePath = 'tsconfig.json'; + + if (!tree.exists(tsconfigBasePath)) return; + + const tsconfigBaseContent = readJson(tree, tsconfigBasePath); + + if (!tsconfigBaseContent.compilerOptions) + tsconfigBaseContent.compilerOptions = {}; + tsconfigBaseContent.compilerOptions.skipLibCheck = true; + + writeJson(tree, tsconfigBasePath, tsconfigBaseContent); +} + export function configureTsProjectConfig( tree: Tree, schema: StorybookConfigureSchema