Skip to content

W-21523405 feat: Add TypeScript component generation with intelligent defaulting#877

Open
shugo111 wants to merge 10 commits intomainfrom
feat/typescript-component-generation
Open

W-21523405 feat: Add TypeScript component generation with intelligent defaulting#877
shugo111 wants to merge 10 commits intomainfrom
feat/typescript-component-generation

Conversation

@shugo111
Copy link
Copy Markdown
Collaborator

@shugo111 shugo111 commented Mar 20, 2026

Summary

Enables TypeScript component generation with intelligent language detection - @W-21523405@

  • Add TypeScript templates for LWC components (.ts files)
  • Intelligent template defaulting based on sfdx-project.json defaultLWCLanguage
  • --template typescript flag for explicit TypeScript component creation
  • NUT tests for TypeScript component generation

Related Work Items

  • WI-011: Add TypeScript template for LWC components
  • WI-012: Add --template typescript flag to component generate command
  • WI-013: Implement intelligent template defaulting based on project preference
  • WI-015: Add NUT tests for TypeScript component generation

Test Plan

  • Components generate with .ts extension in TypeScript projects
  • Components respect --template typescript flag override
  • Default behavior maintained for JavaScript projects
  • NUT tests pass for all scenarios

Dependencies

IMPORTANT: This PR is built on top of #876 and must be merged AFTER #876.

Base PRs:

  1. W-21523324 feat:Add TypeScript project templates with dist/ folder strategy forcedotcom/salesforcedx-templates#758 (templates)
  2. W-21523376: feat: Add --lwc-language flag to project generate command #876 (project generation)

Note

⚠️ Snapshot files need to be updated for the new flags. This can be done during review.

Epic

Epic 2: CLI - Component Generation (Part of TypeScript for LWC initiative)

@shugo111 shugo111 requested a review from a team as a code owner March 20, 2026 16:49
@salesforce-cla
Copy link
Copy Markdown

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Shubham Goyal <s***@s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, refresh the status of this Pull Request.

@shugo111 shugo111 changed the title feat: Add TypeScript component generation with intelligent defaulting W-21523405 feat: Add TypeScript component generation with intelligent defaulting Mar 24, 2026
shugo111 added a commit that referenced this pull request Mar 26, 2026
Address PR #877 review comments:

- Fix naming convention: defaultLWCLanguage → defaultLwcLanguage
  (aligns with Salesforce camelCase convention like sfdcLoginUrl, sourceApiVersion)

- Update flag documentation:
  - Add "Default is 'javascript'" to summary
  - Remove dist/ folder references (in-place compilation)
  - Fix deployment strategy: deploy .js files, exclude .ts files

- Update intelligent defaulting to use correct field name

Files changed:
- component.ts: Fixed defaultLwcLanguage references
- messages/project.md: Updated flag summary and description
- messages/lightning.md: Fixed field name reference
- README.md: Updated all documentation (4 locations)
- Test files: Updated assertions to use correct field name

Related: @W-21523405@
shugo111 added 10 commits March 26, 2026 17:28
  W-21523318

  - Added --lwc-language flag with options: javascript, typescript
  - Added concise flag documentation in messages/project.md
  - Flag is optional and backward compatible
  - Validation ensures only valid values accepted
  @W-21523380@

  Add comprehensive NUT test suite for TypeScript project functionality
  covering all acceptance criteria: tsconfig.json with outDir: "dist"
  configuration, TypeScript dependencies in package.json, ESLint config
  using single @typescript-eslint/parser for both .js and .ts files,
  proper .forceignore/.gitignore exclusions for dist/ folder, and
  sfdx-project.json defaultLWCLanguage field.

  Includes backward compatibility tests confirming JavaScript projects
  remain unaffected when --lwc-language javascript is specified or flag
  is omitted. All 179 tests passing.
  @W-21523390@

  Add comprehensive documentation for TypeScript project creation covering
  architecture and usage patterns. Updates include TypeScript project
  generation examples, detailed explanation of dist/ folder strategy for
  local compilation vs. server-side type stripping, and enhanced CLI help
  text with flag descriptions.

  New "TypeScript Support for Lightning Web Components" section explains
  dual-mode approach: local type validation with npm run build (compiles
  to dist/) and server deployment of raw .ts files. Includes complete
  workflow example from project creation through deployment.
  @W-21523405@

  Add TypeScript template option to lightning component generation command,
  allowing developers to generate LWC components with .ts files instead of
  .js files. Component template generates TypeScript syntax with proper LWC
  decorators and type annotations. Test files are generated as .test.ts in
  __tests__/ folder.

  Updated CLI to accept --template typeScript flag and added example to
  help text. TypeScript template was already present in salesforcedx-templates
  repository, this change exposes it through the CLI command options.
  @W-21523414@

  Implement automatic template selection for Lightning Web Component
  generation based on project's defaultLWCLanguage preference in
  sfdx-project.json. When --template flag is not specified, CLI
  automatically selects TypeScript template for projects with
  "defaultLWCLanguage": "typescript" and JavaScript template for
  "defaultLWCLanguage": "javascript".

  Explicit --template flag always overrides project preference. Updated
  help text to document automatic template selection behavior. Only
  applies to LWC components, not Aura components.
  @W-21523425@

  Add comprehensive NUT test coverage for TypeScript Lightning Web
  Component generation including explicit template flag usage, automatic
  template selection based on project preference, and template override
  behavior. Tests verify .ts and .test.ts file creation, absence of .js
  files in TypeScript components, proper class naming conventions, and
  intelligent defaulting logic.

  Five new test cases cover: explicit TypeScript template generation,
  automatic TypeScript selection in TypeScript projects, automatic
  JavaScript selection in JavaScript projects, explicit template override
  in TypeScript projects, and proper PascalCase/camelCase naming. All
  162 NUT tests passing.
Add lwc-language flag to template:generate:project command snapshot
to resolve deprecation policy check failures.
- Fix help text from 'Defaults to javascript' to 'If not specified, the project uses JavaScript'
- Add intelligent defaulting for LWC components based on sfdx-project.json defaultLWCLanguage
- Use this.argv to detect explicit --template flag instead of relying on flag defaults
- Add test coverage for TypeScript component generation and invalid lwc-language values
Address PR #877 review comments:

- Fix naming convention: defaultLWCLanguage → defaultLwcLanguage
  (aligns with Salesforce camelCase convention like sfdcLoginUrl, sourceApiVersion)

- Update flag documentation:
  - Add "Default is 'javascript'" to summary
  - Remove dist/ folder references (in-place compilation)
  - Fix deployment strategy: deploy .js files, exclude .ts files

- Update intelligent defaulting to use correct field name

Files changed:
- component.ts: Fixed defaultLwcLanguage references
- messages/project.md: Updated flag summary and description
- messages/lightning.md: Fixed field name reference
- README.md: Updated all documentation (4 locations)
- Test files: Updated assertions to use correct field name

Related: @W-21523405@
@shugo111 shugo111 force-pushed the feat/typescript-component-generation branch from 0c59fca to aad95cd Compare March 26, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants