import * as ts from "typescript" ; import { DecoratorDescriptionSource } from "./declarations" ; import { getTypeFullName } from "./helpers" ; export function getDecorators ( symbol , checker ) { if ( ! symbol . valueDeclaration ?. decorators ) { return undefined ; } const decorators = [ ] ; for ( let decorator of symbol . valueDeclaration . decorators ) { const firstToken = decorator . expression . getFirstToken ( ) ; if ( ! firstToken ) { continue ; } const symbol = checker . getSymbolAtLocation ( firstToken ) ; if ( ! symbol || ! symbol . valueDeclaration ) { continue ; } let decoratorType = checker . getTypeOfSymbolAtLocation ( symbol , symbol . valueDeclaration ) ; decorators . push ( { n : symbol . escapedName . toString ( ) , fn : getTypeFullName ( decoratorType . getSymbol ( ) ) } ) ; } return decorators . length == 0 ? undefined : decorators ; }