Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/schematics/angular/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ function getComponentOptions(options: ApplicationOptions): Partial<ComponentOpti
if (options.fileNameStyleGuide === '2016') {
componentOptions.type = 'component';
componentOptions.addTypeToClassName = false;
} else {
componentOptions.type = '';
}

return componentOptions;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { expectFileNotToExist, expectFileToMatch } from '../../../utils/fs';
import { ng } from '../../../utils/process';
import { updateJsonFile } from '../../../utils/project';

export default async function () {
await updateJsonFile('angular.json', (config) => {
config.schematics = {
'@schematics/angular:component': { type: 'component' },
};
});

for (const style of ['2025', '2016']) {
const project = `app-${style}`;
const appPath = `projects/${project}/src/app`;
const componentName = style === '2016' ? 'app.component' : 'app';

await ng(
'generate',
'application',
project,
`--file-name-style-guide=${style}`,
'--style=css',
'--ssr=false',
'--skip-install',
);
await ng('build', project, '--configuration=development');
await expectFileToMatch(`${appPath}/${componentName}.ts`, `styleUrl: './${componentName}.css'`);
await expectFileNotToExist(`${appPath}/${style === '2016' ? 'app' : 'app.component'}.ts`);
}

// Ordinary component generation should still use the workspace default.
await ng('generate', 'component', 'example', '--project=app-2025', '--skip-tests');
await expectFileToMatch('projects/app-2025/src/app/example/example.component.ts', 'export class');
}
Loading