You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ x ] I have ensured that the issue isn't already reported
[ x ] I have confirmed that the issue is reproducible with the latest released version
[ x ] I have deleted the FEATURE REQUEST / CODE CHANGE section
Summary
getDefaultProps() breaks the native class model of Ember Components.
Expected Behavior
classExampleextendsComponent{layout=hbs`<p>{{this.example}}</p>`propTypes={example: PropTypes.string}getDefautProps(){return{example: "this string should be set as the value of this.example"}}}
prop-types.js:112 Uncaught (in promise) TypeError: defaults.forEach is not a function
at Example.init (prop-types.js:112)
at Example.superWrapper (utils.js:366)
at Example.init (component-prop-types.js:21)
at Example.superWrapper [as init] (utils.js:366)
at initialize (core_object.js:87)
at Function.create (core_object.js:684)
at FactoryManager.create (container.js:545)
at CurlyComponentManager.create (glimmer.js:5437)
at Object.evaluate (runtime.js:1494)
at AppendOpcodes.evaluate (runtime.js:70)
ember new my-app -b @ember/octane-app-blueprint
cd my-app && ember install ember-prop-types
# add component as shown in above examples
ember serve # runtime error in browser
[ x ] Include the contents of your package.json file
[ x ] Steps to reproduce:
Context
I want type checking of props passed to my components in templates. Static type checking is not there yet for ember templates. So it's gotta be run-time. But I don't want to be forced to choose between run-time checks and class syntax
Environment
[ x ] I am using the latest released version (can check with npm ls <package-name>)
I am using these browsers:
[ x ] Latest Chrome
[ x ] My version of Node is: v10.15.2
[ x ] My version of npm is: 6.4.1
[ x ] My OS is: linux-gnu
[ x ] Include the contents of your package.json file
The text was updated successfully, but these errors were encountered:
We moved off this in native class model as we just use typescript to define the interface and
class Example extends Component {
layout = hbs`<p>{{this.example}}</p>`
@argument example: string = "this string should be set as the value of this.example"
}
and the glimmer approach is to go through args so we have something like
interface ExampleArgs {
example: string
}
class Example extends Component<ExampleArgs> {
layout = hbs`<p>{{this.example}}</p>`
example: string
get example (): string {
return this.args.example ?? 'this string should be set as the value of this.example'
}
}
BUG REPORT
Summary
getDefaultProps()
breaks the native class model of Ember Components.Expected Behavior
Actual Behavior
Possible Solution
Steps to Reproduce
https://codesandbox.io/embed/54ojpz0rox
Context
I want type checking of props passed to my components in templates. Static type checking is not there yet for ember templates. So it's gotta be run-time. But I don't want to be forced to choose between run-time checks and class syntax
Environment
npm ls <package-name>
)Node
is: v10.15.2npm
is: 6.4.1The text was updated successfully, but these errors were encountered: