Resources:
Before submitting an issue, please consult our docs.
Stencil version: (run npm list @stencil/core from a terminal/cmd prompt and paste output below):
$ npm list @stencil/core
my-name@0.0.1 /Users/samuelmortenson/repos/stencil-getter
└── @stencil/core@0.0.6-10
I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://stencil-worldwide.slack.com
Current behavior:
If you add a @Method to a component and use the get keyword in front of the function name, the component will compile incorrectly leading to a Uncaught ReferenceError: Method is not defined error when loaded in a web browser.
Expected behavior:
I would expect that Stencil elements could expose getter/setter methods using @Method. These accessors are super useful, especially when trying to emulate the behavior of something like the <input> element's "value" attribute. It can get set as an initial property, and the attribute never changes in the DOM, but when input.value is called the current value is returned. Would be great to do something similar in Stencil.
Steps to reproduce:
git clone git@github.com:mortenson/stencil-getter.git
cd stencil-getter && npm install && npm start
See Uncaught ReferenceError: Method is not defined in your web browser.
Related code:
Here's the syntax I would expect to expose a getter/setter:
@Method()
get value() {
return Math.random();
}
(ref https://github.com/mortenson/stencil-getter/blob/master/src/components/my-name/my-name.tsx#L12)
Other information:
Here's the TypeScript documentation on Accessors (get/set): https://www.typescriptlang.org/docs/handbook/classes.html#accessors
Resources:
Before submitting an issue, please consult our docs.
Stencil version: (run
npm list @stencil/corefrom a terminal/cmd prompt and paste output below):I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://stencil-worldwide.slack.com
Current behavior:
If you add a
@Methodto a component and use thegetkeyword in front of the function name, the component will compile incorrectly leading to aUncaught ReferenceError: Method is not definederror when loaded in a web browser.Expected behavior:
I would expect that Stencil elements could expose getter/setter methods using
@Method. These accessors are super useful, especially when trying to emulate the behavior of something like the<input>element's "value" attribute. It can get set as an initial property, and the attribute never changes in the DOM, but wheninput.valueis called the current value is returned. Would be great to do something similar in Stencil.Steps to reproduce:
git clone git@github.com:mortenson/stencil-getter.gitcd stencil-getter && npm install && npm startSee
Uncaught ReferenceError: Method is not definedin your web browser.Related code:
Here's the syntax I would expect to expose a getter/setter:
(ref https://github.com/mortenson/stencil-getter/blob/master/src/components/my-name/my-name.tsx#L12)
Other information:
Here's the TypeScript documentation on Accessors (get/set): https://www.typescriptlang.org/docs/handbook/classes.html#accessors