@@ -339,6 +339,123 @@ describe('template generate project:', () => {
339339 } ) ;
340340 } ) ;
341341
342+ describe ( 'TypeScript project creation' , ( ) => {
343+ it ( 'should create TypeScript project with all required files' , ( ) => {
344+ execCmd ( 'template generate project --projectname tsproject --lwc-language typescript' , { ensureExitCode : 0 } ) ;
345+
346+ // Verify standard files exist
347+ assert . file ( [ path . join ( session . project . dir , 'tsproject' , 'config' , 'project-scratch-def.json' ) ] ) ;
348+ assert . file ( [ path . join ( session . project . dir , 'tsproject' , 'README.md' ) ] ) ;
349+ assert . file ( [ path . join ( session . project . dir , 'tsproject' , 'sfdx-project.json' ) ] ) ;
350+
351+ // Verify TypeScript-specific files exist
352+ assert . file ( [ path . join ( session . project . dir , 'tsproject' , 'tsconfig.json' ) ] ) ;
353+ assert . file ( [ path . join ( session . project . dir , 'tsproject' , 'package.json' ) ] ) ;
354+ assert . file ( [ path . join ( session . project . dir , 'tsproject' , 'eslint.config.js' ) ] ) ;
355+ assert . file ( [ path . join ( session . project . dir , 'tsproject' , '.forceignore' ) ] ) ;
356+ assert . file ( [ path . join ( session . project . dir , 'tsproject' , '.gitignore' ) ] ) ;
357+ } ) ;
358+
359+ it ( 'should verify tsconfig.json has correct TypeScript configuration' , ( ) => {
360+ execCmd ( 'template generate project --projectname tsconfig-test --lwc-language typescript' , { ensureExitCode : 0 } ) ;
361+
362+ const tsconfigPath = path . join ( session . project . dir , 'tsconfig-test' , 'tsconfig.json' ) ;
363+ assert . file ( [ tsconfigPath ] ) ;
364+ assert . fileContent ( tsconfigPath , '"erasableSyntaxOnly": true' ) ;
365+ assert . fileContent ( tsconfigPath , '"include"' ) ;
366+ assert . fileContent ( tsconfigPath , 'force-app/**/*.ts' ) ;
367+ assert . fileContent ( tsconfigPath , '"exclude"' ) ;
368+ assert . fileContent ( tsconfigPath , '**/__tests__/**' ) ;
369+ } ) ;
370+
371+ it ( 'should verify .forceignore excludes dist/ folder' , ( ) => {
372+ execCmd ( 'template generate project --projectname forceignore-test --lwc-language typescript' , {
373+ ensureExitCode : 0 ,
374+ } ) ;
375+
376+ const forceignorePath = path . join ( session . project . dir , 'forceignore-test' , '.forceignore' ) ;
377+ assert . file ( [ forceignorePath ] ) ;
378+ assert . fileContent ( forceignorePath , 'tsconfig.json' ) ;
379+ assert . fileContent ( forceignorePath , '**/tsconfig.*.json' ) ;
380+ } ) ;
381+
382+ it ( 'should verify .gitignore excludes TypeScript build artifacts' , ( ) => {
383+ execCmd ( 'template generate project --projectname gitignore-test --lwc-language typescript' , {
384+ ensureExitCode : 0 ,
385+ } ) ;
386+
387+ const gitignorePath = path . join ( session . project . dir , 'gitignore-test' , '.gitignore' ) ;
388+ assert . file ( [ gitignorePath ] ) ;
389+ assert . fileContent ( gitignorePath , '*.tsbuildinfo' ) ;
390+ } ) ;
391+
392+ it ( 'should verify package.json has TypeScript dependencies' , ( ) => {
393+ execCmd ( 'template generate project --projectname packagejson-test --lwc-language typescript' , {
394+ ensureExitCode : 0 ,
395+ } ) ;
396+
397+ const packageJsonPath = path . join ( session . project . dir , 'packagejson-test' , 'package.json' ) ;
398+ assert . file ( [ packageJsonPath ] ) ;
399+ assert . fileContent ( packageJsonPath , '"typescript"' ) ;
400+ assert . fileContent ( packageJsonPath , '"@typescript-eslint/eslint-plugin"' ) ;
401+ assert . fileContent ( packageJsonPath , '"@typescript-eslint/parser"' ) ;
402+ assert . fileContent ( packageJsonPath , '"@types/jest"' ) ;
403+ assert . fileContent ( packageJsonPath , '"build": "tsc"' ) ;
404+ assert . fileContent ( packageJsonPath , '"build:watch": "tsc --watch"' ) ;
405+ } ) ;
406+
407+ it ( 'should verify sfdx-project.json includes defaultLwcLanguage field' , ( ) => {
408+ execCmd ( 'template generate project --projectname sfdx-test --lwc-language typescript' , { ensureExitCode : 0 } ) ;
409+
410+ const sfdxProjectPath = path . join ( session . project . dir , 'sfdx-test' , 'sfdx-project.json' ) ;
411+ assert . file ( [ sfdxProjectPath ] ) ;
412+ assert . fileContent ( sfdxProjectPath , '"defaultLwcLanguage": "typescript"' ) ;
413+ } ) ;
414+
415+ it ( 'should verify ESLint config uses TypeScript parser for both JS and TS' , ( ) => {
416+ execCmd ( 'template generate project --projectname eslint-test --lwc-language typescript' , { ensureExitCode : 0 } ) ;
417+
418+ const eslintConfigPath = path . join ( session . project . dir , 'eslint-test' , 'eslint.config.js' ) ;
419+ assert . file ( [ eslintConfigPath ] ) ;
420+ assert . fileContent ( eslintConfigPath , "files: ['**/lwc/**/*.{js,ts}']" ) ;
421+ assert . fileContent ( eslintConfigPath , 'parser: tseslint.parser' ) ;
422+ assert . fileContent ( eslintConfigPath , '@typescript-eslint' ) ;
423+ } ) ;
424+
425+ it ( 'should create JavaScript project without TypeScript files when using javascript flag' , ( ) => {
426+ execCmd ( 'template generate project --projectname jsproject --lwc-language javascript' , { ensureExitCode : 0 } ) ;
427+
428+ // TypeScript files should NOT exist
429+ assert . noFile ( [ path . join ( session . project . dir , 'jsproject' , 'tsconfig.json' ) ] ) ;
430+
431+ // Standard files should exist
432+ assert . file ( [ path . join ( session . project . dir , 'jsproject' , 'package.json' ) ] ) ;
433+ assert . file ( [ path . join ( session . project . dir , 'jsproject' , 'eslint.config.js' ) ] ) ;
434+
435+ // Verify sfdx-project.json has javascript as default
436+ const sfdxProjectPath = path . join ( session . project . dir , 'jsproject' , 'sfdx-project.json' ) ;
437+ assert . fileContent ( sfdxProjectPath , '"defaultLwcLanguage": "javascript"' ) ;
438+
439+ // Verify package.json does NOT have TypeScript dependencies
440+ const packageJsonPath = path . join ( session . project . dir , 'jsproject' , 'package.json' ) ;
441+ const packageContent = fs . readFileSync ( packageJsonPath , 'utf8' ) ;
442+ expect ( packageContent ) . to . not . contain ( 'typescript' ) ;
443+ expect ( packageContent ) . to . not . contain ( '@typescript-eslint' ) ;
444+ } ) ;
445+
446+ it ( 'should create default project without TypeScript files when no flag specified' , ( ) => {
447+ execCmd ( 'template generate project --projectname defaultproject' , { ensureExitCode : 0 } ) ;
448+
449+ // TypeScript files should NOT exist
450+ assert . noFile ( [ path . join ( session . project . dir , 'defaultproject' , 'tsconfig.json' ) ] ) ;
451+
452+ // sfdx-project.json should NOT have defaultLwcLanguage field
453+ const sfdxProjectPath = path . join ( session . project . dir , 'defaultproject' , 'sfdx-project.json' ) ;
454+ const sfdxContent = fs . readFileSync ( sfdxProjectPath , 'utf8' ) ;
455+ expect ( sfdxContent ) . to . not . contain ( 'defaultLwcLanguage' ) ;
456+ } ) ;
457+ } ) ;
458+
342459 describe ( 'project creation failures' , ( ) => {
343460 it ( 'should throw missing required flag error' , ( ) => {
344461 const stderr = execCmd ( 'template generate project' ) . shellOutput . stderr ;
0 commit comments