ng-packagr / ng-packagr

Compile and package Angular libraries in Angular Package Format (APF)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"TaskCategoryCodes" is not exported by "dist/valueSets/esm2020/lib/sets/tak/TaskCategoryCodes.mjs", imported by "dist/valueSets/esm2020/public-api.mjs".

stefanbernhardweb opened this issue · comments

✖ Generating FESM2020
"TaskCategoryCodes" is not exported by "dist/valueSets/esm2020/lib/sets/tak/TaskCategoryCodes.mjs"imported by "dist/valueSets/esm2020/public-api.mjs"

[x ] Bug Report
[ ] Feature Request

When I want to build my own library and I don't use the * to import all exported consts and types into the public-api.ts I always get the error above.

How To Reproduce

Build a new library and remove all automatically created files in the lib folder. After that create a own file that has follow content:

export declare const TaskCategoryCodes: {
  readonly Completed: "completed";
  readonly EnteredInError: "entered-in-error";
  readonly InProgress: "in-progress";
  readonly Stopped: "stopped";
};

export declare type TaskCategoryCodesType=
  (typeof TaskCategoryCodes)[keyof typeof TaskCategoryCodes];

Than import this file into the public-api.ts and into the components or services you want to use this codes in your angular project. Now execute the build-statement, to build the library-files.

Expected Behaviour

Build process works.

Version Information

ng-packagr:            15.2.2
@angular/compiler:     15.1.0
rollup:                3.28.1
typescript:            4.8.4

I've found out that the error only occurs if I export the constant TaskCategoryCodes. If I only export the TaskCategoryCodesType the build works fine. The thing is, that I need this constant in my angular project.

You need to replace export declare with just export since you are not writing a Type definition file. Also, you might want to consider using a enum

export enum TaskCategoryCodes {
  Completed = "completed",
  EnteredInError = "entered-in-error",
  InProgress = "in-progress",
  Stopped = "stopped",
}

I understand. That was my mistake. Thank you.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

This action has been performed automatically by a bot.