Skip to content

fix: allow readonly map entry constructor#2123

Merged
jdeniau merged 1 commit into
immutable-js:mainfrom
septs:ro-map
Jun 11, 2025
Merged

fix: allow readonly map entry constructor#2123
jdeniau merged 1 commit into
immutable-js:mainfrom
septs:ro-map

Conversation

@septs

@septs septs commented Jun 11, 2025

Copy link
Copy Markdown
Contributor

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

septs commented Jun 11, 2025

Copy link
Copy Markdown
Contributor Author

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

jdeniau commented Jun 11, 2025

Copy link
Copy Markdown
Member

Nice catch 👍

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

jdeniau commented Jun 11, 2025

Copy link
Copy Markdown
Member

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