feat(compiler): Added support for limited function calls in metadata. (#9125)
The collector now collects the body of functions that return an expression as a symbolic 'function'. The static reflector supports expanding these functions statically to allow provider macros. Also added support for the array spread operator in both the collector and the static reflector.
This commit is contained in:
@ -61,6 +61,15 @@ export function isConstructorMetadata(value: any): value is ConstructorMetadata
|
||||
return value && value.__symbolic === 'constructor';
|
||||
}
|
||||
|
||||
export interface FunctionMetadata {
|
||||
__symbolic: 'function';
|
||||
parameters: string[];
|
||||
result: MetadataValue;
|
||||
}
|
||||
export function isFunctionMetadata(value: any): value is FunctionMetadata {
|
||||
return value && value.__symbolic === 'function';
|
||||
}
|
||||
|
||||
export type MetadataValue = string | number | boolean | MetadataObject | MetadataArray |
|
||||
MetadataSymbolicExpression | MetadataError;
|
||||
|
||||
@ -69,7 +78,7 @@ export interface MetadataObject { [name: string]: MetadataValue; }
|
||||
export interface MetadataArray { [name: number]: MetadataValue; }
|
||||
|
||||
export interface MetadataSymbolicExpression {
|
||||
__symbolic: 'binary'|'call'|'index'|'new'|'pre'|'reference'|'select'
|
||||
__symbolic: 'binary'|'call'|'index'|'new'|'pre'|'reference'|'select'|'spread'
|
||||
}
|
||||
export function isMetadataSymbolicExpression(value: any): value is MetadataSymbolicExpression {
|
||||
if (value) {
|
||||
@ -81,6 +90,7 @@ export function isMetadataSymbolicExpression(value: any): value is MetadataSymbo
|
||||
case 'pre':
|
||||
case 'reference':
|
||||
case 'select':
|
||||
case 'spread':
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -190,6 +200,15 @@ export function isMetadataSymbolicSelectExpression(value: any):
|
||||
return value && value.__symbolic === 'select';
|
||||
}
|
||||
|
||||
export interface MetadataSymbolicSpreadExpression extends MetadataSymbolicExpression {
|
||||
__symbolic: 'spread';
|
||||
expression: MetadataValue;
|
||||
}
|
||||
export function isMetadataSymbolicSpreadExpression(value: any):
|
||||
value is MetadataSymbolicSpreadExpression {
|
||||
return value && value.__symbolic === 'spread';
|
||||
}
|
||||
|
||||
export interface MetadataError {
|
||||
__symbolic: 'error';
|
||||
|
||||
|
Reference in New Issue
Block a user