From 680a58a3a3a46fce0b3b1db0b0161331e81260f3 Mon Sep 17 00:00:00 2001 From: mad-jose Date: Fri, 6 Nov 2020 11:52:03 +0530 Subject: [PATCH 1/2] appTsConfig immutability handling by immer --- .../scripts/utils/verifyTypeScriptSetup.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js b/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js index 04e6e4e0020..3872667045a 100644 --- a/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js +++ b/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js @@ -236,7 +236,9 @@ function verifyTypeScriptSetup() { if (suggested != null) { if (parsedCompilerOptions[option] === undefined) { - appTsConfig.compilerOptions[option] = suggested; + appTsConfig = immer(appTsConfig, config => { + config.compilerOptions[option] = suggested; + }); messages.push( `${coloredOption} to be ${chalk.bold( 'suggested' @@ -244,7 +246,9 @@ function verifyTypeScriptSetup() { ); } } else if (parsedCompilerOptions[option] !== valueToCheck) { - appTsConfig.compilerOptions[option] = value; + appTsConfig = immer(appTsConfig, config => { + config.compilerOptions[option] = value; + }); messages.push( `${coloredOption} ${chalk.bold( valueToCheck == null ? 'must not' : 'must' @@ -256,7 +260,9 @@ function verifyTypeScriptSetup() { // tsconfig will have the merged "include" and "exclude" by this point if (parsedTsConfig.include == null) { - appTsConfig.include = ['src']; + appTsConfig = immer(appTsConfig, config => { + config.include = ['src']; + }); messages.push( `${chalk.cyan('include')} should be ${chalk.cyan.bold('src')}` ); From d61d3aaa1237f7eb47266143e231f2c6af587de3 Mon Sep 17 00:00:00 2001 From: mad-jose <44253495+josezone@users.noreply.github.com> Date: Tue, 24 Nov 2020 06:36:17 +0530 Subject: [PATCH 2/2] Remove stringify --- .../scripts/utils/verifyTypeScriptSetup.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js b/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js index 3872667045a..949f34ab7d2 100644 --- a/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js +++ b/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js @@ -218,15 +218,7 @@ function verifyTypeScriptSetup() { if (appTsConfig.compilerOptions == null) { appTsConfig.compilerOptions = {}; firstTimeSetup = true; - } else { - // This is bug fix code of https://github.com/facebook/create-react-app/issues/9868 - // Bellow code release variable from non-extensible and freeze status. - appTsConfig.compilerOptions = JSON.parse(JSON.stringify(appTsConfig.compilerOptions)); - - // Original appTsConfig.compilerOptions status - // Object.isExtensible(appTsConfig.compilerOptions) output: false - // Object.isFrozen(appTsConfig.compilerOptions) output: true - } + } for (const option of Object.keys(compilerOptions)) { const { parsedValue, value, suggested, reason } = compilerOptions[option];