props-bindable
Simon Holthausen 9 months ago
parent 1d818380dd
commit 6f274ac914

@ -969,9 +969,7 @@ function validate_no_const_assignment(node, argument, scope, is_binding) {
function validate_assignment(node, argument, state) { function validate_assignment(node, argument, state) {
validate_no_const_assignment(node, argument, state.scope, false); validate_no_const_assignment(node, argument, state.scope, false);
if (!state.analysis.runes) return; if (state.analysis.runes && argument.type === 'Identifier') {
if (argument.type === 'Identifier') {
const binding = state.scope.get(argument.name); const binding = state.scope.get(argument.name);
if (binding?.kind === 'derived') { if (binding?.kind === 'derived') {
error(node, 'invalid-derived-assignment'); error(node, 'invalid-derived-assignment');
@ -982,17 +980,17 @@ function validate_assignment(node, argument, state) {
} }
} }
let obj = /** @type {import('estree').Expression | import('estree').Super} */ (argument); let object = /** @type {import('estree').Expression | import('estree').Super} */ (argument);
/** @type {import('estree').Expression | import('estree').PrivateIdentifier | null} */ /** @type {import('estree').Expression | import('estree').PrivateIdentifier | null} */
let property = null; let property = null;
while (obj.type === 'MemberExpression') { while (object.type === 'MemberExpression') {
property = obj.property; property = object.property;
obj = obj.object; object = object.object;
} }
if (obj.type === 'ThisExpression' && property?.type === 'PrivateIdentifier') { if (object.type === 'ThisExpression' && property?.type === 'PrivateIdentifier') {
if (state.private_derived_state.includes(property.name)) { if (state.private_derived_state.includes(property.name)) {
error(node, 'invalid-derived-assignment'); error(node, 'invalid-derived-assignment');
} }

@ -488,10 +488,7 @@ export function client_component(source, analysis, options) {
/** @type {import('estree').Property[]} */ /** @type {import('estree').Property[]} */
const props_str = []; const props_str = [];
for (const [name, binding] of analysis.instance.scope.declarations) { for (const [name, binding] of properties) {
if ((binding.kind !== 'prop' && binding.kind !== 'bindable_prop') || name.startsWith('$$'))
continue;
const key = binding.prop_alias ?? name; const key = binding.prop_alias ?? name;
const prop_def = typeof ce === 'boolean' ? {} : ce.props?.[key] || {}; const prop_def = typeof ce === 'boolean' ? {} : ce.props?.[key] || {};
if ( if (

Loading…
Cancel
Save