Skip to content

[🐞] optimizer gets confused about props #7665

Open
@wmertens

Description

@wmertens

Which component is affected?

Qwik Optimizer (rust)

Describe the bug

When using component$(({foo, bar, ...props}) => ...) it's possible to refer to the destructured props and the full props, and the optimizer will redeclare props when restructuring.

Reproduction

https://qwik.dev/playground/#f=Q0o0RqYW2BKNDkoKBvPARRvuxIQnLdkA6xw7DQ2Q%2BTn5RTqQxgO0DeEHLLGKgWGd55yRmJeeCrQqGVToAiNFR0FPTw%2Fc3FCohYcgSr6CBCzYUE0uiCSk%2FEWEuAKkwaKXnJEKLDJSgCK1YKXQmFDPyFQHpuLRRDwEEzEA

Steps to reproduce

import { component$, useComputed$, useTask$ } from '@builder.io/qwik'

export default component$<any>(({ color, class: classNames, onChange$, children, ...props }) => {
  useComputed$(() => color)

  useTask$(() => {
    props.checked
  })

  return 'hi'
})

System Info

web

Additional Information

happens in v1 and v2.

Workaround: name the rest props something else

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions