import { objectLiteralToObjectMap } from '../transform-utils' ; import ts from 'typescript' ; export const getDeclarationParameters = ( decorator ) : any => { if ( ! ts . isCallExpression ( decorator . expression ) ) { return [ ] ; } return decorator . expression . arguments . map ( getDeclarationParameter ) ; } ; const getDeclarationParameter = ( arg ) : any => { if ( ts . isObjectLiteralExpression ( arg ) ) { return objectLiteralToObjectMap ( arg ) ; } else if ( ts . isStringLiteral ( arg ) ) { return arg . text ; } throw new Error ( `invalid decorator argument: ${ arg . getText ( ) }` ) ; } ; export const isDecoratorNamed = ( propName ) => { return ( dec ) : boolean => { return ts . isCallExpression ( dec . expression ) && dec . expression . expression . getText ( ) === propName ; } ; } ; export interface GetDeclarationParameters { < T > ( decorator ) : [ T ] ; < T , T1 > ( decorator ) : [ T , T1 ] ; < T , T1 , T2 > ( decorator ) : [ T , T1 , T2 ] ; }