refactor(core): stronger type for resolved angular decorators (#29608)
PR Close #29608
This commit is contained in:
parent
780081def0
commit
15eb1e0ce1
|
@ -62,7 +62,7 @@ function getInputNamesFromMetadata(
|
|||
return null;
|
||||
}
|
||||
|
||||
const decoratorCall = decorator.node.expression as ts.CallExpression;
|
||||
const decoratorCall = decorator.node.expression;
|
||||
|
||||
// In case the decorator does define any metadata, there is no metadata
|
||||
// where inputs could be declared. This is an edge case because there
|
||||
|
|
|
@ -16,7 +16,7 @@ import {NgQueryDefinition, QueryTiming} from './angular/query-definition';
|
|||
*/
|
||||
export function getTransformedQueryCallExpr(
|
||||
query: NgQueryDefinition, timing: QueryTiming): ts.CallExpression|null {
|
||||
const queryExpr = query.decorator.node.expression as ts.CallExpression;
|
||||
const queryExpr = query.decorator.node.expression;
|
||||
const queryArguments = queryExpr.arguments;
|
||||
const timingPropertyAssignment = ts.createPropertyAssignment(
|
||||
'static', timing === QueryTiming.STATIC ? ts.createTrue() : ts.createFalse());
|
||||
|
|
|
@ -9,9 +9,13 @@
|
|||
import * as ts from 'typescript';
|
||||
import {getCallDecoratorImport} from './typescript/decorators';
|
||||
|
||||
export type CallExpressionDecorator = ts.Decorator & {
|
||||
expression: ts.CallExpression;
|
||||
}
|
||||
|
||||
export interface NgDecorator {
|
||||
name: string;
|
||||
node: ts.Decorator;
|
||||
node: CallExpressionDecorator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,5 +26,7 @@ export function getAngularDecorators(
|
|||
typeChecker: ts.TypeChecker, decorators: ReadonlyArray<ts.Decorator>): NgDecorator[] {
|
||||
return decorators.map(node => ({node, importData: getCallDecoratorImport(typeChecker, node)}))
|
||||
.filter(({importData}) => importData && importData.importModule.startsWith('@angular/'))
|
||||
.map(({node, importData}) => ({node, name: importData !.name}));
|
||||
.map(
|
||||
({node, importData}) =>
|
||||
({node: node as CallExpressionDecorator, name: importData !.name}));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue