usage field may contain null, but the TypeScript type definition does not reflect this #1402
Open
1 task done
Labels
bug
Something isn't working
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
Issue Title
usage
field may containnull
, but its type does not reflect thisIssue Description
The
usage
field in the response is described in the documentation as follows:However, the TypeScript type definition does not include
null
as a possible value:Since the field explicitly states that it can be
null
in most cases (except for the last chunk), the correct type definition should be:This mismatch may cause issues in TypeScript projects that rely on strict type checking.
openai-node/src/resources/chat/completions/completions.ts
Lines 377 to 386 in 20e97a4
To Reproduce
This is a clear bug since the comments and the actual code do not match.
Code snippets
OS
macOS
Node version
Node v22.3.0
Library version
4.87.4
The text was updated successfully, but these errors were encountered: