Skip to content

Subclassing Builtins #14415

@abdel-17

Description

@abdel-17

Describe the problem

JavaScript supports subclassing builtins like Array, but it seems Svelte doesn't proxy subclasses of Array. Yeah yeah, I know inheritance is disgusting and OOP is evil or whatever, but I have a valid use case where I need additional properties/methods on the array. I have an example below.

Example

Currently, I have a class with a current property that's an array, but it would be more convenient to have the class itself be an array.

Describe the proposed solution

Make $state work with subclasses of Array. Not sure if there are performance implications here.

Importance

nice to have

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