Created
November 2, 2017 22:15
-
-
Save aluanhaddad/11c8ad3b37809bfdd097835a1c1d5d88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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