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 names on exported enum are ignored #780

@SLaks

Description

@SLaks

JS:

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

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



/**
 * Converts a boolean into a TriState enum.
 * @param {boolean} bool
 * @return {!TriState}
 */
exports.fromBool = function(bool) {
  return bool ? TriState.TRUE : TriState.FALSE;
};

TS:

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;
}

The correct way to emit this is via namespace merging:

http://www.typescriptlang.org/play/#src=%2F**%0D%0A%20*%20Representation%20of%20a%20tri-state%20boolean.%0D%0A%20*%2F%0D%0Aenum%20TriState%20%7B%0D%0A%20%20%20%20FALSE%20%3D%20'FALSE'%20%2C%0D%0A%20%20%20%20TRUE%20%3D%20'TRUE'%20%2C%0D%0A%20%20%20%20UNKNOWN%20%3D%20'UNKNOWN'%20%2C%0D%0A%7D%0D%0A%0D%0Anamespace%20TriState%20%7B%0D%0A%20%20%20%20export%20function%20fromBool(bool%3A%20boolean)%20%7B%0D%0A%20%20%20%20%20%20%20%20return%20bool%20%3F%20TriState.TRUE%20%3A%20TriState.FALSE%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0Aconst%20x%20%3D%20TriState.fromBool(true)%3B%0D%0A

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