Class NominalTypeBuilder

java.lang.Object
com.google.javascript.rhino.NominalTypeBuilder

public class NominalTypeBuilder extends Object
Builder interface for declaring properties on class-like (nominal) types. Nominal types consist primarily of three separate object types, which may each have their own properties declared on them separately: (1) the constructor function, (2) the instance type, and (3) the prototype object.

This builder is used during the first part of type checking, while the type checker builds up the set of known types. Thus, this interface serves as a placeholder to allow operating on (i.e. both assigning properties to, and referencing the yet-to-exist type) these not-yet-available types.

  • Constructor Details

  • Method Details

    • declarePrototypeProperty

      public void declarePrototypeProperty(String name, JSType type, Node defSite)
      Declares a property on the nominal type's prototype.
    • declareInstanceProperty

      public void declareInstanceProperty(String name, JSType type, Node defSite)
      Declares an instance property on the nominal type.
    • declareConstructorProperty

      public void declareConstructorProperty(String name, JSType type, Node defSite)
      Declares a static property on the nominal type's constructor.
    • superClass

      public @Nullable NominalTypeBuilder superClass()
      Returns a NominalTypeBuilder for this type's superclass.
    • constructor

      public FunctionType constructor()
      Returns the constructor as a JSType.
    • instance

      public ObjectType instance()
      Returns the instance type as a JSType.
    • prototypeOrInstance

      public ObjectType prototypeOrInstance()
      Returns the type of the prototype object (OTI).