Skip to content

missing allowEmpty type in CreateCommitOptions due to new GitLab API change #3825

Description

@Kuroson

Description

  • Node.js version: 24.12.0
  • Gitbeaker version: 43.8.0
  • Gitbeaker release (cli, rest, core, requester-utils): @gitbeaker/core
  • OS & version: N/A

A GitLab regression was introduced last year which prevented empty commits from being created via the GitLab API. This was recently fixed in this GitLab PR. As a resulf of that PR's changes, a new optional argument allow_empty and allowEmpty has been introduced. This has not been added to the types as of yet.

Steps to reproduce

Example code:

import { Gitlab } from '@gitbeaker/rest';

const api = new Gitlab({
  host: 'https://gitlab.com',
  token: 'your-token',
});

await api.Commits.create(
  projectID,
  branchName,
  'Commit message',
  [], // empty actions, i.e., empty commit
  {
    startProject: startProject,
    startSha: startSHA,
    allowEmpty: true, // TypeScript error: Property 'allowEmpty' does not exist
  },
);

Expected behaviour

The allowEmpty option should be recognized as a valid optional parameter in the Commits.create() method's type definition.

Actual behaviour

A typescript error:

Object literal may only specify known properties, and 'allowEmpty' does not exist in type 'CreateCommitOptions & Sudo & ShowExpanded<false>'.

Possible fixes

Introduce this type into CreateCommitOptions and possibly other places if necessary.

Checklist

  • I have checked that this is not a duplicate issue.
  • I have read the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:typesAdding or enhancing typescript types

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions