fix(ivy): fix type error in newer version of TS (#22897)
Newer version of TS is stricter about types and flags counter-variant types in some situations. This change inlines the DirectiveDefArgs into the arguments which: 1) removes the inheritance which caused the issue and 2) Makes it more friendly to IDEs since they will not report comments. Closes #22877 Closes #22843 PR Close #22897
This commit is contained in:
@ -192,135 +192,6 @@ export interface PipeDef<T> {
|
||||
onDestroy: (() => void)|null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for `defineDirective`
|
||||
*/
|
||||
export interface DirectiveDefArgs<T> {
|
||||
/**
|
||||
* Directive type, needed to configure the injector.
|
||||
*/
|
||||
type: Type<T>;
|
||||
|
||||
/**
|
||||
* Factory method used to create an instance of directive.
|
||||
*/
|
||||
factory: () => T | ({0: T} & any[]); /* trying to say T | [T, ...any] */
|
||||
|
||||
/**
|
||||
* Static attributes to set on host element.
|
||||
*
|
||||
* Even indices: attribute name
|
||||
* Odd indices: attribute value
|
||||
*/
|
||||
attributes?: string[];
|
||||
|
||||
/**
|
||||
* A map of input names.
|
||||
*
|
||||
* The format is in: `{[actualPropertyName: string]:string}`.
|
||||
*
|
||||
* Which the minifier may translate to: `{[minifiedPropertyName: string]:string}`.
|
||||
*
|
||||
* This allows the render to re-construct the minified and non-minified names
|
||||
* of properties.
|
||||
*/
|
||||
inputs?: {[P in keyof T]?: string};
|
||||
|
||||
/**
|
||||
* A map of output names.
|
||||
*
|
||||
* The format is in: `{[actualPropertyName: string]:string}`.
|
||||
*
|
||||
* Which the minifier may translate to: `{[minifiedPropertyName: string]:string}`.
|
||||
*
|
||||
* This allows the render to re-construct the minified and non-minified names
|
||||
* of properties.
|
||||
*/
|
||||
outputs?: {[P in keyof T]?: string};
|
||||
|
||||
/**
|
||||
* A list of optional features to apply.
|
||||
*
|
||||
* See: {@link NgOnChangesFeature}, {@link PublicFeature}
|
||||
*/
|
||||
features?: DirectiveDefFeature[];
|
||||
|
||||
/**
|
||||
* Function executed by the parent template to allow child directive to apply host bindings.
|
||||
*/
|
||||
hostBindings?: (directiveIndex: number, elementIndex: number) => void;
|
||||
|
||||
/**
|
||||
* Defines the name that can be used in the template to assign this directive to a variable.
|
||||
*
|
||||
* See: {@link Directive.exportAs}
|
||||
*/
|
||||
exportAs?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for `defineComponent`.
|
||||
*/
|
||||
export interface ComponentDefArgs<T> extends DirectiveDefArgs<T> {
|
||||
/**
|
||||
* HTML tag name to use in place where this component should be instantiated.
|
||||
*/
|
||||
tag: string;
|
||||
|
||||
/**
|
||||
* Template function use for rendering DOM.
|
||||
*
|
||||
* This function has following structure.
|
||||
*
|
||||
* ```
|
||||
* function Template<T>(ctx:T, creationMode: boolean) {
|
||||
* if (creationMode) {
|
||||
* // Contains creation mode instructions.
|
||||
* }
|
||||
* // Contains binding update instructions
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Common instructions are:
|
||||
* Creation mode instructions:
|
||||
* - `elementStart`, `elementEnd`
|
||||
* - `text`
|
||||
* - `container`
|
||||
* - `listener`
|
||||
*
|
||||
* Binding update instructions:
|
||||
* - `bind`
|
||||
* - `elementAttribute`
|
||||
* - `elementProperty`
|
||||
* - `elementClass`
|
||||
* - `elementStyle`
|
||||
*
|
||||
*/
|
||||
template: ComponentTemplate<T>;
|
||||
|
||||
/**
|
||||
* A list of optional features to apply.
|
||||
*
|
||||
* See: {@link NgOnChancesFeature}, {@link PublicFeature}
|
||||
*/
|
||||
features?: ComponentDefFeature[];
|
||||
|
||||
rendererType?: RendererType2;
|
||||
|
||||
changeDetection?: ChangeDetectionStrategy;
|
||||
|
||||
/**
|
||||
* Defines the set of injectable objects that are visible to a Directive and its light DOM
|
||||
* children.
|
||||
*/
|
||||
providers?: Provider[];
|
||||
|
||||
/**
|
||||
* Defines the set of injectable objects that are visible to its view DOM children.
|
||||
*/
|
||||
viewProviders?: Provider[];
|
||||
}
|
||||
|
||||
export type DirectiveDefFeature = <T>(directiveDef: DirectiveDef<T>) => void;
|
||||
export type ComponentDefFeature = <T>(componentDef: ComponentDef<T>) => void;
|
||||
|
||||
|
Reference in New Issue
Block a user