ts-morph-structures

Home > ts-morph-structures > ClassMembersMap

ClassMembersMap class

A map for class methods, properties, accessors and a constructor. This doesn’t replace ClassDeclarationImpl, rather, it _feeds_ ClassDeclarationImpl.

Signature:

export default class ClassMembersMap extends OrderedMap<string, ClassMemberImpl> 

Extends: OrderedMap<string, ClassMemberImpl>

Example

const map = new ClassMembersMap; const foo = new PropertyDeclarationImpl(false, “foo”); map.addMembers([foo]); // … const classDecl = new ClassDeclarationImpl; classDecl.name = “FooClass”; map.moveMembersToClass(classDecl); // classDecl.properties === [foo];

Methods

Method Modifiers Description
addMembers(members)   Add class members as values of this map, using standard keys.
arrayOfKind(kind)   Get class members of a particular kind.
clone()   Get a clone of this map.
convertAccessorsToProperty(isStatic, name)   Convert get and/or set accessors to a property. This may be lossy, but we try to be faithful.
convertPropertyToAccessors(isStatic, name, toGetter, toSetter)   Convert a property to get and/or set accessors. This may be lossy, but we try to be faithful.
convertTypeMembers(isStatic, typeMembers, map) static Creata an array of class members from an array of type members,
fromClassDeclaration(classDecl) static Create a ClassMembersMap from a class declaration.
getAsKind(kind, isStatic, name)   A typed call to this.get() for a given kind.
keyFromMember(member) static Get a map key from a potential class member.
keyFromName(kind, isStatic, name) static  
moveMembersToClass(classDecl)   Move class members from this map to a class declaration, and clear this map.
moveStatementsToMembers(statementsMaps)   Move statements from a sequence of statement maps to the class members.
toJSON()