Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
export type Constructor = new (...args: any[]) => any;
export type Decorator = (target: Constructor) => Constructor;
export declare function NgModule<P1, P2, P3, P4, E1, E2, E3, E4>(obj: {providers: [P1, P2, P3, P4], exports: [E1, E2, E3, E4]}): Decorator & typeof obj
export declare function NgModule<P1, P2, P3, E1, E2, E3, E4>(obj: {providers: [P1, P2, P3], exports: [E1, E2, E3, E4]}): Decorator & typeof obj
export declare function NgModule<P1, P2, E1, E2, E3, E4>(obj: {providers: [P1, P2], exports: [E1, E2, E3, E4]}): Decorator & typeof obj
export declare function NgModule<P1, P2, P3, E1, E2, E3>(obj: {providers: [P1, P2, P3], exports: [E1, E2, E3]}): Decorator & typeof obj
export declare function NgModule<P1, E1, E2, E3, E4>(obj: {providers: [P1], exports: [E1, E2, E3, E4]}): Decorator & typeof obj
export declare function NgModule<P1, P2, E1, E2>(obj: {providers: [P1, P2], exports: [E1, E2]}): Decorator & typeof obj
export declare function NgModule<P1, E1, E2>(obj: {providers: [P1], exports: [E1, E2]}): Decorator & typeof obj
export declare function NgModule<P1, E1>(obj: {providers: [P1], exports: [E1]}): Decorator & typeof obj
export declare function NgModule<P1>(obj: {providers: [P1]}): Decorator & typeof obj
export declare function NgModule<E1>(obj: {exports: [E1]}): Decorator & typeof obj;
// exmaple
export declare class ServiceA {}
export declare class ServiceB {}
export declare class ServiceC {}
export declare class ServiceD {}
export declare class ComponentA {}
export declare class ComponentB {}
export declare class ComponentC {}
export declare class ComponentD {}
@NgModule({
providers: [
ServiceA,
ServiceB,
ServiceC,
ServiceD
],
exports: [
ComponentA,
ComponentB,
ComponentC,
ComponentD
]
}) export class AppModule {}
// One problem, Decorators do not "yet" change the type of the decorated class.
// Tracked by issue https://github.com/Microsoft/TypeScript/issues/4881
// In the interim, type information can be captured by writing
const ngModule = NgModule({
providers: [
ServiceA,
ServiceB,
ServiceC,
ServiceD
],
exports: [
ComponentA,
ComponentB,
ComponentC,
ComponentD
]
});
@ngModule export class AppModule {}
export type ModuleMetadata = typeof ngModule;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment