fix(ivy): remove metadata from *Def and introduce *DefWithMeta types (#26203)
Previously in Ivy, metadata for directives/components/modules/etc was carried in .d.ts files inside type information encoded on the DirectiveDef, ComponentDef, NgModuleDef, etc types of Ivy definition fields. This works well, but has the side effect of complicating Ivy's runtime code as these extra generic type parameters had to be specified as <any> throughout the codebase. *DefInternal types were introduced previously to mitigate this issue, but that's the wrong way to solve the problem. This commit returns *Def types to their original form, with no metadata attached. Instead, new *DefWithMeta types are introduced that alias the plain definition types and add extra generic parameters. This way the only code that needs to deal with the extra metadata parameters is the compiler code that reads and writes them - the existence of this metadata is transparent to the runtime, as it should be. PR Close #26203
This commit is contained in:

committed by
Jason Aden

parent
b0070dfb9a
commit
79466baef8
@ -9,7 +9,7 @@
|
||||
import {PipeTransform} from '../change_detection/pipe_transform';
|
||||
|
||||
import {getTView, load, store} from './instructions';
|
||||
import {PipeDefInternal, PipeDefList} from './interfaces/definition';
|
||||
import {PipeDef, PipeDefList} from './interfaces/definition';
|
||||
import {HEADER_OFFSET} from './interfaces/view';
|
||||
import {pureFunction1, pureFunction2, pureFunction3, pureFunction4, pureFunctionV} from './pure_function';
|
||||
|
||||
@ -22,7 +22,7 @@ import {pureFunction1, pureFunction2, pureFunction3, pureFunction4, pureFunction
|
||||
*/
|
||||
export function pipe(index: number, pipeName: string): any {
|
||||
const tView = getTView();
|
||||
let pipeDef: PipeDefInternal<any>;
|
||||
let pipeDef: PipeDef<any>;
|
||||
const adjustedIndex = index + HEADER_OFFSET;
|
||||
|
||||
if (tView.firstTemplatePass) {
|
||||
@ -33,7 +33,7 @@ export function pipe(index: number, pipeName: string): any {
|
||||
])).push(adjustedIndex, pipeDef.onDestroy);
|
||||
}
|
||||
} else {
|
||||
pipeDef = tView.data[adjustedIndex] as PipeDefInternal<any>;
|
||||
pipeDef = tView.data[adjustedIndex] as PipeDef<any>;
|
||||
}
|
||||
|
||||
const pipeInstance = pipeDef.factory();
|
||||
@ -49,7 +49,7 @@ export function pipe(index: number, pipeName: string): any {
|
||||
* @param registry Full list of available pipes
|
||||
* @returns Matching PipeDef
|
||||
*/
|
||||
function getPipeDef(name: string, registry: PipeDefList | null): PipeDefInternal<any> {
|
||||
function getPipeDef(name: string, registry: PipeDefList | null): PipeDef<any> {
|
||||
if (registry) {
|
||||
for (let i = 0; i < registry.length; i++) {
|
||||
const pipeDef = registry[i];
|
||||
@ -151,5 +151,5 @@ export function pipeBindV(index: number, slotOffset: number, values: any[]): any
|
||||
}
|
||||
|
||||
function isPure(index: number): boolean {
|
||||
return (<PipeDefInternal<any>>getTView().data[index + HEADER_OFFSET]).pure;
|
||||
return (<PipeDef<any>>getTView().data[index + HEADER_OFFSET]).pure;
|
||||
}
|
||||
|
Reference in New Issue
Block a user