You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/compiler/validate/js/propValidators/data.js

16 lines
394 B

const disallowed = {
Literal: true,
ObjectExpression: true,
ArrayExpression: true
};
export default function data ( validator, prop ) {
while ( prop.type === 'ParenthesizedExpression' ) prop = prop.expression;
// TODO should we disallow references and expressions as well?
if ( disallowed[ prop.value.type ] ) {
validator.error( `'data' must be a function`, prop.value.start );
}
}