Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export public method ES6 #3105

Open
blooddy opened this issue Oct 12, 2018 · 3 comments
Open

Export public method ES6 #3105

blooddy opened this issue Oct 12, 2018 · 3 comments

Comments

@blooddy
Copy link

blooddy commented Oct 12, 2018

If you compress this code

class Test {
  constructor() {
    this['testMethod']();
  }
  'testMethod'() {
    return true;
  }
}
window[ 'Test' ] = Test;

you get this result

class a {
  constructor() {
    this.testMethod();
  }
  ["testMethod"]() {
    return !0;
  }
}
window.Test = a;

it seems to me that the result should be like this

class a {
  constructor() {
    this.testMethod();
  }
  testMethod() {
    return !0;
  }
}
window.Test = a;
@blooddy
Copy link
Author

blooddy commented Oct 12, 2018

And @expose not working =(

class Test {
  constructor() {
    this.testMethod();
  }
  /** @expose */
  testMethod() {
    return true;
  }
}
/** @expose */
window.Test = Test;

output

class a {
  constructor() {
  }
}
window.Test = a;

@lauraharker
Copy link
Contributor

Repro for the initial issue
Looks similar to #3071

@expose is deprecated now, but /** @export */ should work. I tried it in the webservice and debugger, and it generates goog.exportProperty and goog.exportSymbol calls in the debugger but not the webservice. Maybe I'm not configuring the webservice options correctly, though.
webservice
debugger

Does using @export instead of @expose work for you?

@lauraharker
Copy link
Contributor

For the first issue, I think we just need to update ConvertToDottedProperties to handle computed properties & methods. Currently it runs in ES6 out mode but doesn't do anything special for ES6 syntax.

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

No branches or pull requests

2 participants