Skip to content

Commit 055d291

Browse files
committed
fix: typeScript to typescript
1 parent 7edf8b9 commit 055d291

3 files changed

Lines changed: 22 additions & 33 deletions

File tree

messages/lightningCmp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
- Generate a TypeScript Lightning web component:
2020

21-
<%= config.bin %> <%= command.id %> --name mycomponent --type lwc --template typeScript
21+
<%= config.bin %> <%= command.id %> --name mycomponent --type lwc --template typescript
2222

2323
# summary
2424

src/commands/template/generate/lightning/component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default class LightningComponent extends SfCommand<CreateOutput> {
3939
default: 'default',
4040
// Note: keep this list here and LightningComponentOptions#template in-sync with the
4141
// templates/lightningcomponents/[aura|lwc]/* folders
42-
options: ['default', 'analyticsDashboard', 'analyticsDashboardWithStep', 'typeScript'] as const,
42+
options: ['default', 'analyticsDashboard', 'analyticsDashboardWithStep', 'typescript'] as const,
4343
})(),
4444
'output-dir': outputDirFlagLightning,
4545
'api-version': orgApiVersionFlagWithDeprecations,
@@ -62,25 +62,23 @@ export default class LightningComponent extends SfCommand<CreateOutput> {
6262
// If template not explicitly provided and generating LWC, check project preference
6363
if (!userExplicitlySetTemplate && flags.type === 'lwc') {
6464
try {
65-
// Try to resolve project from output directory if provided, otherwise use cwd
6665
const projectPath = flags['output-dir'] || process.cwd();
6766
const project = await SfProject.resolve(projectPath);
6867
const projectJson = await project.resolveProjectConfig();
6968
const defaultLwcLanguage = projectJson.defaultLwcLanguage as string | undefined;
7069

7170
if (defaultLwcLanguage === 'typescript') {
72-
template = 'typeScript';
71+
template = 'typescript';
7372
}
74-
// If defaultLwcLanguage is undefined or non-typescript, template remains default.
7573
} catch (error) {
76-
// Not in a project context or project config not available, use default
7774
this.debug('Could not resolve project config for intelligent defaulting:', error);
7875
}
7976
}
8077

8178
const flagsAsOptions: LightningComponentOptions = {
8279
componentname: flags.name,
83-
template,
80+
// Temp re-mapping to allow lowercase typescript flag
81+
template: template === 'typescript' ? 'typeScript' : template,
8482
outputdir: flags['output-dir'],
8583
apiversion: flags['api-version'],
8684
internal: flags.internal,

test/commands/template/generate/lightning/component.nut.ts

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe('template generate lightning component:', () => {
168168
describe('TypeScript Lightning web component generation', () => {
169169
it('should create TypeScript LWC with explicit template flag', () => {
170170
execCmd(
171-
'template generate lightning component --componentname tsComponent --outputdir lwc --type lwc --template typeScript',
171+
'template generate lightning component --componentname tsComponent --outputdir lwc --type lwc --template typescript',
172172
{ ensureExitCode: 0 }
173173
);
174174

@@ -307,7 +307,7 @@ describe('template generate lightning component:', () => {
307307

308308
it('should create TypeScript component with proper class naming', () => {
309309
execCmd(
310-
'template generate lightning component --componentname mySpecialComponent --outputdir lwc --type lwc --template typeScript',
310+
'template generate lightning component --componentname mySpecialComponent --outputdir lwc --type lwc --template typescript',
311311
{ ensureExitCode: 0 }
312312
);
313313

@@ -357,9 +357,9 @@ describe('template generate lightning component:', () => {
357357
);
358358
});
359359

360-
it('should throw error when using typeScript template with aura type', () => {
360+
it('should throw error when using typescript template with aura type', () => {
361361
const stderr = execCmd(
362-
'template generate lightning component --outputdir aura --componentname foo --type aura --template typeScript'
362+
'template generate lightning component --outputdir aura --componentname foo --type aura --template typescript'
363363
).shellOutput.stderr;
364364
expect(stderr).to.contain(messages.getMessage('MissingLightningComponentTemplate', ['typeScript', 'aura']));
365365
});
@@ -368,43 +368,34 @@ describe('template generate lightning component:', () => {
368368
describe('Component generation outside project context', () => {
369369
it('should create JavaScript component outside project with no template flag', () => {
370370
// Generate component in a directory without sfdx-project.json
371-
execCmd('template generate lightning component --componentname outsideComponent --outputdir standalone/lwc --type lwc', {
372-
ensureExitCode: 0,
373-
});
371+
execCmd(
372+
'template generate lightning component --componentname outsideComponent --outputdir standalone/lwc --type lwc',
373+
{
374+
ensureExitCode: 0,
375+
}
376+
);
374377

375378
// Verify JavaScript files were created (default when no project context)
376-
assert.file(
377-
path.join(session.project.dir, 'standalone', 'lwc', 'outsideComponent', 'outsideComponent.js')
378-
);
379-
assert.file(
380-
path.join(session.project.dir, 'standalone', 'lwc', 'outsideComponent', 'outsideComponent.html')
381-
);
379+
assert.file(path.join(session.project.dir, 'standalone', 'lwc', 'outsideComponent', 'outsideComponent.js'));
380+
assert.file(path.join(session.project.dir, 'standalone', 'lwc', 'outsideComponent', 'outsideComponent.html'));
382381

383382
// Verify no TypeScript file
384-
assert.noFile(
385-
path.join(session.project.dir, 'standalone', 'lwc', 'outsideComponent', 'outsideComponent.ts')
386-
);
383+
assert.noFile(path.join(session.project.dir, 'standalone', 'lwc', 'outsideComponent', 'outsideComponent.ts'));
387384
});
388385

389386
it('should create TypeScript component outside project with explicit template flag', () => {
390387
// Generate TypeScript component outside project
391388
execCmd(
392-
'template generate lightning component --componentname outsideTsComponent --outputdir standalone/lwc --type lwc --template typeScript',
389+
'template generate lightning component --componentname outsideTsComponent --outputdir standalone/lwc --type lwc --template typescript',
393390
{ ensureExitCode: 0 }
394391
);
395392

396393
// Verify TypeScript files were created
397-
assert.file(
398-
path.join(session.project.dir, 'standalone', 'lwc', 'outsideTsComponent', 'outsideTsComponent.ts')
399-
);
400-
assert.file(
401-
path.join(session.project.dir, 'standalone', 'lwc', 'outsideTsComponent', 'outsideTsComponent.html')
402-
);
394+
assert.file(path.join(session.project.dir, 'standalone', 'lwc', 'outsideTsComponent', 'outsideTsComponent.ts'));
395+
assert.file(path.join(session.project.dir, 'standalone', 'lwc', 'outsideTsComponent', 'outsideTsComponent.html'));
403396

404397
// Verify no JavaScript file
405-
assert.noFile(
406-
path.join(session.project.dir, 'standalone', 'lwc', 'outsideTsComponent', 'outsideTsComponent.js')
407-
);
398+
assert.noFile(path.join(session.project.dir, 'standalone', 'lwc', 'outsideTsComponent', 'outsideTsComponent.js'));
408399
});
409400
});
410401
});

0 commit comments

Comments
 (0)