Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Exported enum from goog.module() breaks Clutz #779

Open
@SLaks

Description

@SLaks

JS:

goog.module('hr.util.TriState');
goog.module.declareLegacyNamespace();

/**
 * Representation of a tri-state boolean.
 * @enum {string}
 */
const TriState = {
  UNKNOWN: 'UNKNOWN',
  FALSE: 'FALSE',
  TRUE: 'TRUE',
};

exports = TriState;

Clutz generates:

declare namespace ಠ_ಠ.clutz.hr.util {
  //!! hr.util.TriState aliases enum module$contents$hr$util$TriState_TriState
  type TriState = module$contents$hr$util$TriState_TriState ;
  const TriState : typeof module$contents$hr$util$TriState_TriState ;
}
declare module 'goog:hr.util.TriState' {
  import TriState = ಠ_ಠ.clutz.hr.util.TriState;
  export default TriState;
}

This does not work at all.

Assigning the enum object directly to exports in the JS fixes, and generates

declare namespace ಠ_ಠ.clutz.hr.util {
  /**
   * Representation of a tri-state boolean.
   */
  enum TriState {
    FALSE = 'FALSE' ,
    TRUE = 'TRUE' ,
    UNKNOWN = 'UNKNOWN' ,
  }
}
declare module 'goog:hr.util.TriState' {
  import TriState = ಠ_ಠ.clutz.hr.util.TriState;
  export default TriState;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions