From e09e8d3d607e9edb5a38af790f753309aa1aea3d Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 30 Dec 2022 11:39:42 -0500 Subject: [PATCH 1/2] CLI: Add prop-types dependency if not using TypeScript --- code/lib/cli/src/generators/REACT/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/code/lib/cli/src/generators/REACT/index.ts b/code/lib/cli/src/generators/REACT/index.ts index 0bf8bb0ba23b..50eb2019b918 100644 --- a/code/lib/cli/src/generators/REACT/index.ts +++ b/code/lib/cli/src/generators/REACT/index.ts @@ -1,8 +1,19 @@ +import { detectLanguage } from '../../detect'; +import { SupportedLanguage } from '../../project_types'; import { baseGenerator } from '../baseGenerator'; import type { Generator } from '../types'; const generator: Generator = async (packageManager, npmOptions, options) => { - await baseGenerator(packageManager, npmOptions, options, 'react'); + // Add prop-types dependency if not using TypeScript + const extraPackages = []; + const language = detectLanguage(); + if (language === SupportedLanguage.JAVASCRIPT) { + extraPackages.push('prop-types'); + } + + await baseGenerator(packageManager, npmOptions, options, 'react', { + extraPackages, + }); }; export default generator; From f0000d814e124e980ba7b18199baef2ac4b1efd9 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 30 Dec 2022 12:00:29 -0500 Subject: [PATCH 2/2] Update code/lib/cli/src/generators/REACT/index.ts Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --- code/lib/cli/src/generators/REACT/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/lib/cli/src/generators/REACT/index.ts b/code/lib/cli/src/generators/REACT/index.ts index 50eb2019b918..c37ebc323f99 100644 --- a/code/lib/cli/src/generators/REACT/index.ts +++ b/code/lib/cli/src/generators/REACT/index.ts @@ -5,11 +5,8 @@ import type { Generator } from '../types'; const generator: Generator = async (packageManager, npmOptions, options) => { // Add prop-types dependency if not using TypeScript - const extraPackages = []; const language = detectLanguage(); - if (language === SupportedLanguage.JAVASCRIPT) { - extraPackages.push('prop-types'); - } + const extraPackages = language === SupportedLanguage.JAVASCRIPT ? ['prop-types'] : []; await baseGenerator(packageManager, npmOptions, options, 'react', { extraPackages,