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

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

Open
SLaks opened this issue Sep 5, 2018 · 1 comment
Open

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

SLaks opened this issue Sep 5, 2018 · 1 comment

Comments

@SLaks
Copy link
Contributor

SLaks commented Sep 5, 2018

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;
}
@rkirov
Copy link
Contributor

rkirov commented Sep 8, 2018

Clutz has issues with goog.module.declareLegacyNamespace(); you can also try removing that line, which I think would fix the issue too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants