Skip to content

[oracledb] Correct callback style type definition to allow error as null and optional return value for success#74833

Merged
typescript-bot merged 3 commits intoDefinitelyTyped:masterfrom
sudarshan12s:fixtypesforcallbacks
Apr 14, 2026
Merged

[oracledb] Correct callback style type definition to allow error as null and optional return value for success#74833
typescript-bot merged 3 commits intoDefinitelyTyped:masterfrom
sudarshan12s:fixtypesforcallbacks

Conversation

@sudarshan12s
Copy link
Copy Markdown
Contributor

This fixes the issue reported here

It fixes the callback style type definition for all the APIs accepting callbacks.

Please fill in this template.

Select one of these and delete the others:

If adding a new definition:

  • The package does not already provide its own types, or cannot have its .d.ts files generated via --declaration
  • If this is for an npm package, match the name. If not, do not conflict with the name of an npm package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
  • Represents shape of module/library correctly
  • tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: <>
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the package.json.

If removing a declaration:

  • If a package was never on Definitely Typed, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.)
  • Delete the package's directory.
  • Add it to notNeededPackages.json.

@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Apr 3, 2026

@sudarshan12s Thank you for submitting this PR!

This is a live comment that I will keep updated.

1 package in this PR

Code Reviews

Because this is a widely-used package, a DT maintainer will need to review it before it can be merged.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by a DT maintainer

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 74833,
  "author": "sudarshan12s",
  "headCommitOid": "0760be2912c3a881a3d9a459318d7f54bec2c876",
  "mergeBaseOid": "8fe0c8af85c80359cf96a19fb00e423332cf700f",
  "lastPushDate": "2026-04-03T06:45:15.000Z",
  "lastActivityDate": "2026-04-14T16:10:58.000Z",
  "mergeOfferDate": "2026-04-14T15:29:17.000Z",
  "mergeRequestDate": "2026-04-14T16:10:58.000Z",
  "mergeRequestUser": "sudarshan12s",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "oracledb",
      "kind": "edit",
      "files": [
        {
          "path": "types/oracledb/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/oracledb/oracledb-tests.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "connorjayfitzgerald",
        "dannyb648",
        "jacobwheale",
        "sudarshan12s",
        "sharadraju"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "RyanCavanaugh",
      "date": "2026-04-14T15:28:32.000Z",
      "isMaintainer": true
    },
    {
      "type": "approved",
      "reviewer": "sharadraju",
      "date": "2026-04-14T08:01:30.000Z",
      "isMaintainer": false
    }
  ],
  "mainBotCommentID": 4182178808,
  "ciResult": "pass"
}

@typescript-bot typescript-bot added Critical package Author is Owner The author of this PR is a listed owner of the package. labels Apr 3, 2026
@typescript-bot
Copy link
Copy Markdown
Contributor

🔔 @connorjayfitzgerald @dannyb648 @jacobwheale @sharadraju — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot typescript-bot moved this to Waiting for Code Reviews in Pull Request Status Board Apr 3, 2026
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board Apr 3, 2026
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Code Reviews in Pull Request Status Board Apr 3, 2026
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board Apr 3, 2026
Copy link
Copy Markdown
Member

@RyanCavanaugh RyanCavanaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically someone using an optional parameter in a callback position is mistakenly thinking that it means "is allowed to be ignored by the callee", not "is allowed to be unprovided by the caller". It'd be clearer if all these used | undefined instead.

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Apr 3, 2026
@typescript-bot
Copy link
Copy Markdown
Contributor

@sudarshan12s One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you!

@typescript-bot typescript-bot moved this from Needs Maintainer Review to Needs Author Action in Pull Request Status Board Apr 3, 2026
@sudarshan12s
Copy link
Copy Markdown
Contributor Author

Typically someone using an optional parameter in a callback position is mistakenly thinking that it means "is allowed to be ignored by the callee", not "is allowed to be unprovided by the caller". It'd be clearer if all these used | undefined instead.

Thanks @RyanCavanaugh . If I understand correctly, you're suggesting changing the callback to:

function createPool(poolAttributes: PoolAttributes, callback: (error: DBError | null , pool: Pool | undefined) => void): void;

node-oracledb driver on error invokes the callback with a single argument: (second arg is not sent or remains optional)
callback(error)

on Success with 2 args:
callback(null, pool)

Let me know if I should prefer the stricter (pool: Pool | undefined) for consistency.

@RyanCavanaugh
Copy link
Copy Markdown
Member

For that case you can use a spread tuple:

function foo(cb: (...args: [string] | [null, Error]) => void) {

@sudarshan12s
Copy link
Copy Markdown
Contributor Author

For that case you can use a spread tuple:

function foo(cb: (...args: [string] | [null, Error]) => void) {

If I use above syntax for:

function createPool(poolAttributes: PoolAttributes, callback: (...args: [DBError] | [null, Pool]) => void): void;

I get the following lint error:

Type [T] is a single-element tuple type. You probably meant T[].eslint[@definitelytyped/no-single-element-tuple-type](https://github.com/microsoft/DefinitelyTyped-tools/tree/main/packages/eslint-plugin/docs/rules/no-single-element-tuple-type.md)
interface OracleDB.DBError

I can instead use:

interface ResultCallback<T> {
        (error: DBError): void;
        (error: null): void;
        (error: null, value: T): void;
    }

function createPool(poolAttributes: PoolAttributes, callback: ResultCallback<Pool>): void;

I can then use ResultCallback at all the places applicable (createLob(type: DbType, callback: ResultCallback<Lob>): void; ,... ) . The second one, (error: null): void; is added as there are few cases like for streaming lob write , where we just use cb(null).

Does this approach look reasonable?

Thanks.

@RyanCavanaugh
Copy link
Copy Markdown
Member

You should suppress that lint warning, it's a false positive

@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Apr 9, 2026
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in Pull Request Status Board Apr 9, 2026
@typescript-bot
Copy link
Copy Markdown
Contributor

@RyanCavanaugh Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board Apr 9, 2026
@sudarshan12s
Copy link
Copy Markdown
Contributor Author

You should suppress that lint warning, it's a false positive

Thanks. I have suppressed the warning and made changes , can you take a look ..

// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
    type ResultCallback<T> = (...args: [DBError] | [null, T]) => void;

@typescript-bot typescript-bot added the Unreviewed No one showed up to review this PR, so it'll be reviewed by a DT maintainer. label Apr 14, 2026
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Apr 14, 2026

Re-ping @connorjayfitzgerald, @dannyb648, @jacobwheale:

This PR has been out for over a week, yet I haven't seen any reviews.

Could someone please give it some attention? Thanks!

Copy link
Copy Markdown
Contributor

@sharadraju sharadraju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label Apr 14, 2026
@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner and removed Unreviewed No one showed up to review this PR, so it'll be reviewed by a DT maintainer. labels Apr 14, 2026
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Author to Merge in Pull Request Status Board Apr 14, 2026
@typescript-bot
Copy link
Copy Markdown
Contributor

@sudarshan12s: Everything looks good here. I am ready to merge this PR (at 0760be2) on your behalf whenever you think it's ready.

If you'd like that to happen, please post a comment saying:

Ready to merge

and I'll merge this PR almost instantly. Thanks for helping out! ❤️

(@connorjayfitzgerald, @dannyb648, @jacobwheale, @sharadraju: you can do this too.)

@sudarshan12s
Copy link
Copy Markdown
Contributor Author

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in Pull Request Status Board Apr 14, 2026
@typescript-bot typescript-bot merged commit d6a2768 into DefinitelyTyped:master Apr 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author is Owner The author of this PR is a listed owner of the package. Critical package Maintainer Approved Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner

Projects

Status: Recently Merged

Development

Successfully merging this pull request may close these issues.

4 participants