Native GetAmmoInClip has wrong Typing in TypeScript natives

  1. Client: production
  2. Native documentation suggests this data structure:
const [retval, ammo]: [boolean, number] = 
	GetAmmoInClip(
		ped: Ped, 
		weaponHash: Hash
	);
  1. What actually happens
    Actual typescript native is generated as follows:
declare function GetAmmoInClip(ped: number, weaponHash: string | number, ammo: number): number;
  1. Category of bug: Native
  2. Reproducible steps, preferably with example script(s)

So the problem is not the native itself, but the typings generated to Typescript.
Typescript typing should be

declare function GetAmmoInClip(ped: number, weaponHash: string | number, ammo: number): [number, number];

I have tried to figure out how to build native-doc-tooling and figure out why that happens, but there was no documentation for how to run/build native-doc-tooling.
As a secondary request could we have some documentation regarding how to build/run native-doc-tooling so we can fix issues like that ourselves? :slight_smile:

Natives are rather generated by ext/natives/ in the citizenfx/fivem tree.

However, given your other report, are you certain that the return value is placed correctly in actual execution? There might be multiple anomalies here, indeed.

Correct, the actual return of GetAmmoInClip is 2 item array, which is same as documentation states.

I’ll take a look at ext/natives, maybe I’ll be able to figure it out myself :slight_smile:

So, I have been looking at the code that generates docs.
I weren’t able to manage to build fivem to generate the inp folder to run the codegen.
Is there a way to run codegen without building fivem?
It needs inp/natives_global.lua file that, by my assumption, comes from building fivem.

But here’s my current hypothesis:

I think this check is naive/incorrect, by always assuming that if the argument is single pointer - it’s an input.

Can’t test it myself as I’m too dumb to figure out that inp folder.
Will try to work on it a little bit more, maybe I’ll able to figure out how to build :slight_smile:

Okay, I think I have solution for TS typings:

That should make typings actually correct and behave as they should.