import * as ts from "typescript" ; import { GetTypeCall } from "./declarations" ; import { createValueExpression } from "./createValueExpression" ; import { getTypeDescription } from "./getTypeDescription" ; import { Context } from "./contexts/Context" ; const createdTypes = new Map < number , ts . ObjectLiteralExpression > ( ) ; param symbol param type param context param typeCtor export default function getTypeCall ( type , symbol , context , typeCtor ? ) { const id = ( type . symbol as any ) ?. [ "id" ] ; let typePropertiesObjectLiteral = undefined ; if ( id ) { typePropertiesObjectLiteral = createdTypes . get ( id ) ; } if ( ! typePropertiesObjectLiteral ) { const props = getTypeDescription ( type , symbol , context , typeCtor ) ; typePropertiesObjectLiteral = createValueExpression ( props ) as ts . ObjectLiteralExpression ; } const getTypeIdentifier = context . getGetTypeIdentifier ( ) ; if ( id ) { context . addTypeMetadata ( [ id , typePropertiesObjectLiteral ] ) ; return ts . factory . createCallExpression ( getTypeIdentifier , [ ] , [ ts . factory . createNumericLiteral ( id ) ] ) ; } return ts . factory . createCallExpression ( getTypeIdentifier , [ ] , [ typePropertiesObjectLiteral ] ) ; }