Skip to content

Readonly Array for PluggableList #266

@pcorpet

Description

@pcorpet

Initial checklist

Affected package

[email protected]

Steps to reproduce

I'm using the React Markdown library which is using unified as a dependency, especially the plugins. The main component can take a list of plugins with a PluggableList which is mutable. However I believe this is not meant to be modified but to handover an immutable list of plugins.

const REMARK_PLUGINS = [remarkGfm] as const

...
const processor = unified()
    .use(REMARK_PLUGINS)

Before opening a bug at ReactMarkdown, I want to check in here:

  • is there an alternative which is readonly for PluggableList? (I could not find one)
  • is PluggableList actually mostly used as readonly and you would consider making it ReadonlyArray? at least that the use function would take it as an immutable array?

If you believe that it should actually stay mutable for some reason, I'll reach out to ReactMarkdown.

Actual behavior

This makes the Typescript check fails as REMARK_PLUGINS is readonly (due to the as const) while use expects a PluggableList which is mutable.

Expected behavior

Typescript should not choke and use should accept a readonly array of plugins.

Runtime

No response

Package manager

No response

Operating system

No response

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions