feat(ivy): capture the identifier of a decorator during reflection (#26860)
Previously the ReflectionHost API only returned the names of decorators and not a reference to their TypeScript Identifier. This commit adds the identifier itself, so that a consumer can write references to the decorator. Testing strategy: this commit is trivial, and the functionality will be exercised by downstream tests. PR Close #26860
This commit is contained in:
parent
4dfa71f018
commit
84e311038d
|
@ -572,6 +572,7 @@ export class Fesm2015ReflectionHost extends TypeScriptReflectionHost implements
|
||||||
const decoratorIdentifier = decoratorExpression;
|
const decoratorIdentifier = decoratorExpression;
|
||||||
return {
|
return {
|
||||||
name: decoratorIdentifier.text,
|
name: decoratorIdentifier.text,
|
||||||
|
identifier: decoratorIdentifier,
|
||||||
import: this.getImportOfIdentifier(decoratorIdentifier),
|
import: this.getImportOfIdentifier(decoratorIdentifier),
|
||||||
node: call,
|
node: call,
|
||||||
args: Array.from(call.arguments)
|
args: Array.from(call.arguments)
|
||||||
|
@ -634,6 +635,7 @@ export class Fesm2015ReflectionHost extends TypeScriptReflectionHost implements
|
||||||
if (typeIdentifier && ts.isIdentifier(typeIdentifier)) {
|
if (typeIdentifier && ts.isIdentifier(typeIdentifier)) {
|
||||||
decorators.push({
|
decorators.push({
|
||||||
name: typeIdentifier.text,
|
name: typeIdentifier.text,
|
||||||
|
identifier: typeIdentifier,
|
||||||
import: this.getImportOfIdentifier(typeIdentifier), node,
|
import: this.getImportOfIdentifier(typeIdentifier), node,
|
||||||
args: getDecoratorArgs(node),
|
args: getDecoratorArgs(node),
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,6 +20,11 @@ export interface Decorator {
|
||||||
*/
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifier which refers to the decorator in source.
|
||||||
|
*/
|
||||||
|
identifier: ts.Identifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `Import` by which the decorator was brought into the module in which it was invoked, or `null`
|
* `Import` by which the decorator was brought into the module in which it was invoked, or `null`
|
||||||
* if the decorator was declared in the same module and not imported.
|
* if the decorator was declared in the same module and not imported.
|
||||||
|
|
|
@ -245,6 +245,7 @@ export class TypeScriptReflectionHost implements ReflectionHost {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: decoratorExpr.text,
|
name: decoratorExpr.text,
|
||||||
|
identifier: decoratorExpr,
|
||||||
import: importDecl, node, args,
|
import: importDecl, node, args,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue