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

TypeError is emitted when no default value is set on @Input properties #132

Open
mlegenhausen opened this issue Jan 5, 2016 · 5 comments
Labels
Milestone

Comments

@mlegenhausen
Copy link

Using

It should be document that you get an error if you try to assign to an input property without an default value:

@Component({
  selector: 'app',
  template: 'Hello {{ ctrl.value }}'
})
class App {
  // @Input() value; does not work cause the decorators transform will mark the property as not writeable if no initializer is given.
  @Input() value = null; // This works 
}
@panjiesw
Copy link

panjiesw commented Jan 5, 2016

Shouldn't you use it like below?

...
@Input() value;
...

Input and any other decorator returns metadata Function i think...

@mlegenhausen
Copy link
Author

Nice hint I forgot the ().

@timkindberg
Copy link
Contributor

Did that fix it or is it still a bug?

@mlegenhausen
Copy link
Author

The change was introduced to babel-transform-decorators-lagacy here: loganfsmyth/babel-plugin-transform-decorators-legacy@9eefc32

I don't think it is a bug it seems to a feature, but when following the documentation of ng-forward you get an error. I will open an issue at babel-transform-decorators-lagacy.

@mlegenhausen
Copy link
Author

There is already an issue loganfsmyth/babel-plugin-transform-decorators-legacy#14.

@timkindberg timkindberg added the bug label Jan 6, 2016
@timkindberg timkindberg added this to the Milestone 2 milestone Jan 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants