refactor(ivy): make return value of define(Component|Directive|Pipe|Injector|Injectable) private (#23371)
Ivy definition looks something like this: ``` class MyService { static ngInjectableDef = defineInjectable({ … }); } ``` Here the argument to `defineInjectable` is well known public contract which needs to be honored in backward compatible way between versions. The type of the return value of `defineInjectable` on the other hand is private and can change shape drastically between versions without effecting backwards compatibility of libraries publish to NPM. To our users it is effectively an `OpaqueToken`. By prefixing the type with `ɵ` we are communicating the the outside world that the value is not public API and is subject to change without backward compatibility. PR Close #23371
This commit is contained in:

committed by
Igor Minar

parent
f4017ce5e3
commit
2c09b707ce
@ -9,9 +9,10 @@
|
||||
import {PipeTransform} from '../change_detection/pipe_transform';
|
||||
|
||||
import {getTView, load, store} from './instructions';
|
||||
import {PipeDef, PipeDefList} from './interfaces/definition';
|
||||
import {PipeDefList, ɵPipeDef} from './interfaces/definition';
|
||||
import {pureFunction1, pureFunction2, pureFunction3, pureFunction4, pureFunctionV} from './pure_function';
|
||||
|
||||
|
||||
/**
|
||||
* Create a pipe.
|
||||
*
|
||||
@ -21,7 +22,7 @@ import {pureFunction1, pureFunction2, pureFunction3, pureFunction4, pureFunction
|
||||
*/
|
||||
export function pipe(index: number, pipeName: string): any {
|
||||
const tView = getTView();
|
||||
let pipeDef: PipeDef<any>;
|
||||
let pipeDef: ɵPipeDef<any>;
|
||||
|
||||
if (tView.firstTemplatePass) {
|
||||
pipeDef = getPipeDef(pipeName, tView.pipeRegistry);
|
||||
@ -30,7 +31,7 @@ export function pipe(index: number, pipeName: string): any {
|
||||
(tView.pipeDestroyHooks || (tView.pipeDestroyHooks = [])).push(index, pipeDef.onDestroy);
|
||||
}
|
||||
} else {
|
||||
pipeDef = tView.data[index] as PipeDef<any>;
|
||||
pipeDef = tView.data[index] as ɵPipeDef<any>;
|
||||
}
|
||||
|
||||
const pipeInstance = pipeDef.n();
|
||||
@ -44,9 +45,9 @@ export function pipe(index: number, pipeName: string): any {
|
||||
*
|
||||
* @param name Name of pipe to resolve
|
||||
* @param registry Full list of available pipes
|
||||
* @returns Matching PipeDef
|
||||
* @returns Matching ɵPipeDef
|
||||
*/
|
||||
function getPipeDef(name: string, registry: PipeDefList | null): PipeDef<any> {
|
||||
function getPipeDef(name: string, registry: PipeDefList | null): ɵPipeDef<any> {
|
||||
if (registry) {
|
||||
for (let i = 0; i < registry.length; i++) {
|
||||
const pipeDef = registry[i];
|
||||
@ -140,5 +141,5 @@ export function pipeBindV(index: number, values: any[]): any {
|
||||
}
|
||||
|
||||
function isPure(index: number): boolean {
|
||||
return (<PipeDef<any>>getTView().data[index]).pure;
|
||||
return (<ɵPipeDef<any>>getTView().data[index]).pure;
|
||||
}
|
||||
|
Reference in New Issue
Block a user