refactor(ivy): pre-factor: set explicit type parameters for ModuleWithProviders (#25970)
Ivy depends on having the generic type token later when reading the ModuleWithProviders from a .d.ts file. PR Close #25970
This commit is contained in:
parent
96ee898cee
commit
cbbad1b791
|
@ -100,7 +100,7 @@ export class HttpClientXsrfModule {
|
||||||
/**
|
/**
|
||||||
* Disable the default XSRF protection.
|
* Disable the default XSRF protection.
|
||||||
*/
|
*/
|
||||||
static disable(): ModuleWithProviders {
|
static disable(): ModuleWithProviders<HttpClientXsrfModule> {
|
||||||
return {
|
return {
|
||||||
ngModule: HttpClientXsrfModule,
|
ngModule: HttpClientXsrfModule,
|
||||||
providers: [
|
providers: [
|
||||||
|
@ -120,7 +120,7 @@ export class HttpClientXsrfModule {
|
||||||
static withOptions(options: {
|
static withOptions(options: {
|
||||||
cookieName?: string,
|
cookieName?: string,
|
||||||
headerName?: string,
|
headerName?: string,
|
||||||
} = {}): ModuleWithProviders {
|
} = {}): ModuleWithProviders<HttpClientXsrfModule> {
|
||||||
return {
|
return {
|
||||||
ngModule: HttpClientXsrfModule,
|
ngModule: HttpClientXsrfModule,
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -75,7 +75,8 @@ export interface NgModuleDef<T, Declarations, Imports, Exports> {
|
||||||
* @param T the module type. In Ivy applications, this must be explicitly
|
* @param T the module type. In Ivy applications, this must be explicitly
|
||||||
* provided.
|
* provided.
|
||||||
*/
|
*/
|
||||||
export interface ModuleWithProviders<T = any> {
|
export interface ModuleWithProviders<
|
||||||
|
T = any /** TODO(alxhub): remove default when callers pass explicit type param */> {
|
||||||
ngModule: Type<T>;
|
ngModule: Type<T>;
|
||||||
providers?: Provider[];
|
providers?: Provider[];
|
||||||
}
|
}
|
||||||
|
@ -236,7 +237,7 @@ export interface NgModule {
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
imports?: Array<Type<any>|ModuleWithProviders|any[]>;
|
imports?: Array<Type<any>|ModuleWithProviders<{}>|any[]>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The set of components, directives, and pipes declared in this
|
* The set of components, directives, and pipes declared in this
|
||||||
|
|
|
@ -228,7 +228,7 @@ function flatten<T>(values: any[]): T[] {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function expandModuleWithProviders(value: Type<any>| ModuleWithProviders): Type<any> {
|
function expandModuleWithProviders(value: Type<any>| ModuleWithProviders<{}>): Type<any> {
|
||||||
if (isModuleWithProviders(value)) {
|
if (isModuleWithProviders(value)) {
|
||||||
return value.ngModule;
|
return value.ngModule;
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ function wrapReference(value: Type<any>): R3Reference {
|
||||||
return {value: wrapped, type: wrapped};
|
return {value: wrapped, type: wrapped};
|
||||||
}
|
}
|
||||||
|
|
||||||
function isModuleWithProviders(value: any): value is ModuleWithProviders {
|
function isModuleWithProviders(value: any): value is ModuleWithProviders<{}> {
|
||||||
return (value as{ngModule?: any}).ngModule !== undefined;
|
return (value as{ngModule?: any}).ngModule !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ export class FormsModule {
|
||||||
*/
|
*/
|
||||||
static withConfig(opts: {
|
static withConfig(opts: {
|
||||||
/** @deprecated as of v6 */ warnOnDeprecatedNgFormSelector?: 'never' | 'once' | 'always',
|
/** @deprecated as of v6 */ warnOnDeprecatedNgFormSelector?: 'never' | 'once' | 'always',
|
||||||
}): ModuleWithProviders {
|
}): ModuleWithProviders<FormsModule> {
|
||||||
return {
|
return {
|
||||||
ngModule: FormsModule,
|
ngModule: FormsModule,
|
||||||
providers:
|
providers:
|
||||||
|
|
|
@ -70,7 +70,7 @@ export class ServiceWorkerModule {
|
||||||
* workers are not supported by the browser, and the service worker will not be registered.
|
* workers are not supported by the browser, and the service worker will not be registered.
|
||||||
*/
|
*/
|
||||||
static register(script: string, opts: {scope?: string; enabled?: boolean;} = {}):
|
static register(script: string, opts: {scope?: string; enabled?: boolean;} = {}):
|
||||||
ModuleWithProviders {
|
ModuleWithProviders<ServiceWorkerModule> {
|
||||||
return {
|
return {
|
||||||
ngModule: ServiceWorkerModule,
|
ngModule: ServiceWorkerModule,
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -1482,11 +1482,11 @@ export declare class HttpClientModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class HttpClientXsrfModule {
|
export declare class HttpClientXsrfModule {
|
||||||
static disable(): ModuleWithProviders;
|
static disable(): ModuleWithProviders<HttpClientXsrfModule>;
|
||||||
static withOptions(options?: {
|
static withOptions(options?: {
|
||||||
cookieName?: string;
|
cookieName?: string;
|
||||||
headerName?: string;
|
headerName?: string;
|
||||||
}): ModuleWithProviders;
|
}): ModuleWithProviders<HttpClientXsrfModule>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HttpDownloadProgressEvent extends HttpProgressEvent {
|
export interface HttpDownloadProgressEvent extends HttpProgressEvent {
|
||||||
|
|
|
@ -506,7 +506,7 @@ export declare class ModuleWithComponentFactories<T> {
|
||||||
constructor(ngModuleFactory: NgModuleFactory<T>, componentFactories: ComponentFactory<any>[]);
|
constructor(ngModuleFactory: NgModuleFactory<T>, componentFactories: ComponentFactory<any>[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModuleWithProviders<T = any> {
|
export interface ModuleWithProviders<T = any /** TODO(alxhub): remove default when callers pass explicit type param */> {
|
||||||
ngModule: Type<T>;
|
ngModule: Type<T>;
|
||||||
providers?: Provider[];
|
providers?: Provider[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,7 +331,7 @@ export declare class FormGroupName extends AbstractFormGroupDirective implements
|
||||||
|
|
||||||
export declare class FormsModule {
|
export declare class FormsModule {
|
||||||
static withConfig(opts: { warnOnDeprecatedNgFormSelector?: 'never' | 'once' | 'always';
|
static withConfig(opts: { warnOnDeprecatedNgFormSelector?: 'never' | 'once' | 'always';
|
||||||
}): ModuleWithProviders;
|
}): ModuleWithProviders<FormsModule>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class MaxLengthValidator implements Validator, OnChanges {
|
export declare class MaxLengthValidator implements Validator, OnChanges {
|
||||||
|
|
|
@ -3,7 +3,7 @@ export declare class ServiceWorkerModule {
|
||||||
static register(script: string, opts?: {
|
static register(script: string, opts?: {
|
||||||
scope?: string;
|
scope?: string;
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
}): ModuleWithProviders;
|
}): ModuleWithProviders<ServiceWorkerModule>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
|
|
Loading…
Reference in New Issue