import * as ts from "typescript" ; import { Context } from "./contexts/Context" ; import { FunctionLikeDeclarationGenericParametersDetail } from "./FunctionLikeDeclarationGenericParametersDetail" ; import { getGenericParametersDetails } from "./getGenericParametersDetails" ; import getTypeCall from "./getTypeCall" ; import { updateCallExpression } from "./updateCallExpression" ; export function processDecorator ( node , decoratorType , context ) { if ( ! ts . isCallExpression ( node . expression ) ) { return undefined ; } const declaration = decoratorType . symbol . declarations ?. [ 0 ] as ts . FunctionLikeDeclarationBase ; if ( ! declaration ) { return undefined ; } const state = getGenericParametersDetails ( declaration , context , [ ] ) ; if ( ! state || ! state . usedGenericParameters || ! state . indexesOfGenericParameters || ! state . requestedGenericsReflection ) { return undefined ; } const genericParamName = state . usedGenericParameters [ 0 ] ; const genericTypeNode = node . parent ; const genericType = context . typeChecker . getTypeAtLocation ( genericTypeNode ) ; const genericTypeSymbol = genericType . getSymbol ( ) ; return ts . factory . updateDecorator ( node , updateCallExpression ( node . expression , state , [ { genericTypeName : genericParamName , reflectedType : getTypeCall ( genericType , genericTypeSymbol , context , genericTypeNode . name ) } ] ) ) ; }