Skip to content

Empty component 'computed' throws error. #452

Closed
@taylorzane

Description

@taylorzane

An empty component computed property causes svelte compiler to add an unnecessary recompute call without actually adding the recompute function.

Version: 1.13.6

Smallest failing example:

<script>
  export default {
    computed: {} 
  }
</script>

Error: recompute is not defined.

Seems like the error is going on here: src/generators/dom/index.js#L305-L309

In order to resolve this issue I see one of two options:

  1. Check to see if computed is an empty object.
    • I think I'd prefer this more since I (personally) like to scaffold a component before adding in the computed properties.
  2. Throw a warning at build time that an empty object for computed is invalid.

I'll be happy to submit a PR, I just wanted to figure out the best course of action.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions