Merge pull request #115 from nikku/validate-computed-prop

Verify computed property dependencies
pull/120/head
Rich Harris 8 years ago committed by GitHub
commit 3935d05270

@ -21,7 +21,14 @@ export default function computed ( validator, prop ) {
return;
}
computation.value.params.forEach( param => {
const params = computation.value.params;
if ( params.length === 0 ) {
validator.error( `A computed value must depend on at least one property`, computation.value.start );
return;
}
params.forEach( param => {
const valid = param.type === 'Identifier' || param.type === 'AssignmentPattern' && param.left.type === 'Identifier';
if ( !valid ) {

@ -0,0 +1,8 @@
[{
"message": "A computed value must depend on at least one property",
"pos": 49,
"loc": {
"line": 4,
"column": 8
}
}]

@ -0,0 +1,7 @@
<script>
export default {
computed: {
foo: () => {}
}
};
</script>
Loading…
Cancel
Save