fix: change signature of spread_props

pull/11290/head
paoloricciuti 2 years ago
parent 27321f7799
commit c30b98838c

@ -858,7 +858,7 @@ function serialize_inline_component(node, component_name, context) {
? b.object(/** @type {import('estree').Property[]} */ (props_and_spreads[0]) || [])
: b.call(
'$.spread_props',
...props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p)),
b.array(props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p))),
b.array(spreads_keys)
);
/** @param {import('estree').Identifier} node_id */
@ -2995,7 +2995,7 @@ export const template_visitors = {
const props_expression =
spreads.length === 0
? b.object(props)
: b.call('$.spread_props', b.object(props), ...spreads, b.array(spreads_keys));
: b.call('$.spread_props', b.object(props), b.array(spreads), b.array(spreads_keys));
const fallback =
node.fragment.nodes.length === 0
? b.literal(null)

@ -87,7 +87,7 @@ export function rest_props(props, exclude, name) {
* that looks like `() => { dynamic: props }, { static: prop }, ..` and wraps
* them so that the whole thing is passed to the component as the `$$props` argument.
* @template {Record<string | symbol, unknown>} T
* @type {ProxyHandler<{ props: (Array<T | (() => T)>), keys: T }>}}
* @type {ProxyHandler<{ props: (Array<T | (() => T)>), keys: (Array<(() => import('./types.js').Value<string>) | undefined>) }>}}
*/
const spread_props_handler = {
get(target, key) {
@ -159,10 +159,10 @@ const spread_props_handler = {
/**
* @param {Array<Record<string, unknown> | (() => Record<string, unknown>)>} props
* @param {(Array<(() => import('./types.js').Value<string>) | undefined>)} keys
* @returns {any}
*/
export function spread_props(...props) {
const keys = props.pop();
export function spread_props(props, keys) {
return new Proxy({ props, keys }, spread_props_handler);
}

Loading…
Cancel
Save