← All tasks
javascriptoctokit/rest.js #104Not a task: not reproduced

TypeScript signature of issues.setLabels does not allow correct type of labels attribute.

envgap__octokit__rest.js-104

01 / FAILURE SIGNATURE

As reported upstream

Causes the following TypeScript error:
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
6953790a99bd27c097ed5f0c7ca3e2b53bc7263c
Manifest
package.json
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

octokit/rest.js #104 · read the original issue
**Checklist**



- [x] I checked [all open bugs](https://github.com/octokit/rest.js/issues?q=is%3Aissue+label%3Abug) and none of them matched my problem.



**Environment**



- [x] Node.js



**Versions**



```Shell

├── @octokit/auth-app@3.6.0

├── @octokit/rest@18.9.1

```



**What happened?**



The params object type for `rest.issues.setLabels` requires the `labels` attribute to be of type `string[] & { name: string; }[]` I have not found a value that allows this type signature to be satisfied, and I think it is incorrect.



**Minimal test case to reproduce the problem**



```Typescript

export const setIssueLabels = async (

  context: Context,

  labels: string[]

): Promise<void> => {

  await context.client.rest.issues.setLabels({

    issue_number: context.issue.number,

    owner: context.repo.owner,

    repo: context.repo.repo,

    labels: labels,

  });

};

```



Causes the following TypeScript error:

```

Type 'string[]' is not assignable to type 'string[] & { name: string; }[]'.

  Type 'string[]' is not assignable to type '{ name: string; }[]'.

    Type 'string' is not assignable to type '{ name: string; }'

```



The error also occurs when attempting to pass in an array of `{ name: string }`



I know that using a string[] is valid, the above code works, it just requires casting the labels to any.



**What did you expect to happen?**



`string[]` to be an allowed type of `labels` attribute



**What the problem might be**



The type of `labels` attribute should be `string[] | { name: string; }[]` 

Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]