import TypeAliasDeclaration from '../nodes/TypeAliasDeclaration' ; import TypeParameter from '../nodes/TypeParameter' ; import KeyOfKeyword from '../types/KeyOfKeyword' ; import ParenthesizedType from '../types/ParenthesizedType' ; import { Annotation , annotationUtils , Type , CustomType , } from '@manta-style/core' ; description param type param context export function resolveReferencedType ( type ) { let actualType = type ; let annotations = [ ] ; while ( actualType instanceof CustomType || actualType instanceof TypeAliasDeclaration || actualType instanceof TypeParameter || actualType instanceof ParenthesizedType || actualType instanceof KeyOfKeyword ) { if ( actualType instanceof CustomType ) { actualType = actualType . typeForAssignabilityTest ( annotations ) ; } else if ( actualType instanceof TypeAliasDeclaration ) { actualType . deriveLiteral ( annotations ) ; annotations = annotationUtils . inheritAnnotations ( annotations , actualType . getAnnotations ( ) ) ; actualType = actualType . getType ( ) ; } else if ( actualType instanceof TypeParameter ) { actualType = actualType . getActualType ( ) ; } else if ( actualType instanceof KeyOfKeyword ) { actualType = actualType . deriveLiteral ( ) ; } else { actualType = actualType . getType ( ) ; } } return { type : actualType , annotations } ; }