gitbeaker icon indicating copy to clipboard operation
gitbeaker copied to clipboard

Gitlab service camelization types not aligned with Gitlab camelization type

Open jneander opened this issue 2 years ago • 1 comments

Description

I couldn't think of a plainer way of titling this. The Gitlab class accepts a generic flag for camelization, and also infers it from the camelize option passed to the constructor. However, while the behavior of the services is correct by consuming that true|false configuration, the TypeScript types for those services and the data they return continue to indicate no camelization, regardless of the configuration.

  • Node.js version: 16.15.1
  • Gitbeaker version: 35.7.0
  • Gitbeaker release (cli, node, browser, core, requester-utils): core
  • OS & version: macos 12.4

Steps to reproduce

  1. Create an instance of the Gitlab client with the camelize option set to true.
  2. Observe the TypeScript types of any Gitlab service—e.g. client.Groups.
  3. Notice that the "camelize" portion of the types do not match.

Expected behaviour

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

const client = new Gitlab<true>({camelize: true})
// typeof client === Gitlab<true>
// typeof client.Groups === Groups<true>

Actual behaviour

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

const client = new Gitlab<true>({camelize: true})
// typeof client === Gitlab<true>
// typeof client.Groups === Groups<false> (will camelize, but types say otherwise)

Possible fixes

I tired to find an easy fix. But I haven't learned TypeScript well enough to suggest a solution. Sorry.

Checklist

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

I search the open issues and pull requests, but did not see any existing issue related to this. If I missed it, I apologize, and this one can absolutely be closed.

jneander avatar Jul 26 '22 19:07 jneander

Good catch! Ill give it a look

jdalrymple avatar Aug 05 '22 12:08 jdalrymple

Ah, i think the reason why this was acting weird is because the generic variable isnt supposed to be used. Its only there to allow for dynamic typing. If you leave out the generic variable, it should work as intended.

jdalrymple avatar Feb 16 '23 19:02 jdalrymple