我有一个简单的 TypeScript 类,我想将它与一个模块一起打包,并最终使用ng-packagr
.
例如我的班级定义是 -
export class Params {
language: string ;
country: string ;
variant: string ;
dateFormat: string ;
briefDateTimeFormat: string ;
decimalFormat: string ;
}
例如我的模块定义是 -
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Params } from '../params/params';
import { LoginService } from '../sso/login.service';
@NgModule({
imports: [CommonModule],
exports: [Params],
providers: [LoginService]
declarations: [Params, LoginService]
})
export class FoundationModule { }
但是当我尝试导出FoundationModule
in public-api.ts
of 时ng-packagr
,出现以下错误 -
BUILD ERROR
: Unexpected value 'Params in .../params/params.ts' declared by the module 'FoundationModule' in '.../foundation.module.ts'. Please add a @Pipe/@Directive/@Component annotation.
如何在 Angular 模块中打包单个类?