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;
|
||||
return {
|
||||
name: decoratorIdentifier.text,
|
||||
identifier: decoratorIdentifier,
|
||||
import: this.getImportOfIdentifier(decoratorIdentifier),
|
||||
node: call,
|
||||
args: Array.from(call.arguments)
|
||||
|
@ -634,6 +635,7 @@ export class Fesm2015ReflectionHost extends TypeScriptReflectionHost implements
|
|||
if (typeIdentifier && ts.isIdentifier(typeIdentifier)) {
|
||||
decorators.push({
|
||||
name: typeIdentifier.text,
|
||||
identifier: typeIdentifier,
|
||||
import: this.getImportOfIdentifier(typeIdentifier), node,
|
||||
args: getDecoratorArgs(node),
|
||||
});
|
||||
|
|
|
@ -20,6 +20,11 @@ export interface Decorator {
|
|||
*/
|
||||
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`
|
||||
* if the decorator was declared in the same module and not imported.
|
||||
|
|
|
@ -245,6 +245,7 @@ export class TypeScriptReflectionHost implements ReflectionHost {
|
|||
|
||||
return {
|
||||
name: decoratorExpr.text,
|
||||
identifier: decoratorExpr,
|
||||
import: importDecl, node, args,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue