new library public-api.ts file not using component type declared on angular.json's schematics

Open
#26,981 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
angular, typescript
Domain
build-system, cli

Research direction

Start by reproducing ng generate library foo-library with the @schematics/angular:component type setting in angular.json, then inspect the generated projects/foo-library/src/lib/foo-library.cmp.ts and projects/foo-library/src/public-api.ts. Done means public-api.ts exports the generated component using the configured filename suffix rather than .component.

Written by the indexing model from the issue text.

Description

area: @schematics/angular freq1: low severity3: broken type: bug/fix
Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

No

Description

When I create a new library the default component inside of the lib folder takes its type from the component schematic declared on angular.json. If for example my angular.json looks like this:

{
    //...
    "newProjectRoot": "projects",
    //...
    "schematics": {
        "@schematics/angular:application": {
          "style": "scss",
          "inlineTemplate": true,
          "inlineStyle": true,
          "ssr": false
        },
        "@schematics/angular:component": {
          "changeDetection": "OnPush",
          "type": "Cmp",
          "inlineStyle": true,
          "inlineTemplate": true,
          "style": "scss"
        }
    }
}

After creating a library using ng generate library foo-library, the new library includes an empty dummy FooLibraryCmp inside the projects/foo-library/src/lib/foo-library.cmp.ts. However, the contents of projects/foo-library/src/public-api.ts look like this:

/*
 * Public API Surface of foo-library
 */

export * from './lib/foo-library.service';
export * from './lib/foo-library.component'; // uses .component instead of .cmp
Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 17.1.1
Node: 18.18.0
Package Manager: npm 9.6.6
OS: win32 x64

Angular: 17.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1701.1
@angular-devkit/build-angular   17.1.1
@angular-devkit/core            17.1.1
@angular-devkit/schematics      17.1.1
@schematics/angular             17.1.1
ng-packagr                      17.1.2
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.3
Anything else?

No response

Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
16h 35m
Merged PRs (30d)
176

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from angular/angular-cli

All issues in angular/angular-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.