[@std/cbor] [types] Cbor encoding types should allow readonly arrays

Open Beginner friendly
#7,172 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
api

Research direction

Start in the @std/cbor type definitions for CborType, CborStreamInput, and related encoder input types, then run the reproduction with encodeCbor and CborSequenceEncoderStream. Done means readonly number arrays type-check as inputs to both encoding paths without allowing mutation.

Written by the indexing model from the issue text.

Description

bug needs triage

Describe the bug

Cbor.CBORType/CborStreamInput/etc doesn't allow ReadonlyArray. These should be allowed to encoders as CBOR encoding methods don't mutate their inputs.

Steps to Reproduce

import * as CBOR from "jsr:@std/cbor";

const arr: ReadonlyArray<number> = [1, 2, 3];
// Argument of type 'readonly number[]' is not assignable to parameter of type 'CborType'.
CBOR.encodeCbor(arr);

const encoder = new CBOR.CborSequenceEncoderStream(); 
const writer = encoder.getWriter();
// Argument of type 'readonly number[]' is not assignable to parameter of type 'CborStreamInput'.
writer.write(arr);

Expected behavior

These types should be accepted.

Actual behavior

We get a typescript typing error.

Environment

  • OS: Ubuntu 26.04
  • deno version: 2.8.1
  • std version: 0.1.9
Dominant language
TypeScript
Stars
3.6k
Forks
685
Avg merge
10d 11m
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from denoland/std

All issues in denoland/std

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.