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

Aperta
#26,981 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
angular, typescript
Ambito
build-system, cli

Direzione di ricerca

Inizia riproducendo ng generate library foo-library con l'impostazione @schematics/angular:component type in angular.json, quindi esamina i file generati projects/foo-library/src/lib/foo-library.cmp.ts e projects/foo-library/src/public-api.ts. Il lavoro è completato quando public-api.ts esporta il componente generato usando il suffisso del nome file configurato invece di .component.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
27k
Fork
11.8k
Merge medio
16h 35m
PR unite (30g)
176

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di angular/angular-cli

Tutte le issue di angular/angular-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.