Skip to content

fix: allow readonly map entry constructor #2123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged

Conversation

septs
Copy link
Contributor

@septs septs commented Jun 11, 2025

type defintion:

export type CompactTLV = CompactTLV.Entries

export namespace CompactTLV {
  export type Entries = readonly CompactTLV.Entry[]

  export type Entry = readonly [tag: number, value: Uint8Array]
}

converation code:

Map(entries)

error message:

Argument of type 'Entries' is not assignable to parameter of type 'Iterable<[number, Uint8Array<ArrayBufferLike>]>'.
  The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
    Type 'IteratorResult<Entry, undefined>' is not assignable to type 'IteratorResult<[number, Uint8Array<ArrayBufferLike>], any>'.
      Type 'IteratorYieldResult<Entry>' is not assignable to type 'IteratorResult<[number, Uint8Array<ArrayBufferLike>], any>'.
        Type 'IteratorYieldResult<Entry>' is not assignable to type 'IteratorYieldResult<[number, Uint8Array<ArrayBufferLike>]>'.
          The type 'Entry' is 'readonly' and cannot be assigned to the mutable type '[number, Uint8Array<ArrayBufferLike>]'.ts(2345)

@septs
Copy link
Contributor Author

septs commented Jun 11, 2025

readonly array is array subset, will not break compatibility

see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#readonly-tuples

@jdeniau
Copy link
Member

jdeniau commented Jun 11, 2025

Nice catch 👍

@jdeniau jdeniau merged commit b718c4d into immutable-js:main Jun 11, 2025
5 checks passed
@jdeniau
Copy link
Member

jdeniau commented Jun 11, 2025

This has been released in v5.1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy