import ts from 'typescript' ; import { modifier } from './base' ; import * as class_ from './class_' ; import * as node_ from './node' ; import * as object_ from './object_' ; function findOtherProperty < Decl extends ts . GetAccessorDeclaration | ts . SetAccessorDeclaration > ( node ) { const parent = node_ . getParent < ts . GetAccessorDeclaration | ts . SetAccessorDeclaration > ( node ) ; const kind = node . kind === ts . SyntaxKind . GetAccessor ? ts . SyntaxKind . SetAccessor : ts . SyntaxKind . GetAccessor ; const thisName = node_ . getName ( node ) ; let properties ; if ( ts . isClassDeclaration ( parent ) || ts . isClassExpression ( parent ) ) { properties = modifier . isStatic ( node ) ? class_ . getConcreteStaticProperties ( parent ) : class_ . getConcreteInstanceProperties ( parent ) ; } else { properties = object_ . getProperties ( parent ) ; } for ( const prop of properties ) { if ( prop . kind === kind && node_ . getName ( prop ) === thisName ) { return prop as any ; } } return undefined ; } export function getGetAccessor ( node ) { return findOtherProperty ( node ) ; } export function getSetAccessor ( node ) { return findOtherProperty ( node ) ; }