GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(pg): add default export by perrin4869 · Pull Request #72649 · DefinitelyTyped/DefinitelyTyped

Conversation

@perrin4869

@perrin4869 perrin4869 commented Apr 29, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change.
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run pnpm test <package to test>.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: Add esm exports brianc/node-postgres#3423
  • 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.

esm support was officially added in version 8.15, and pg became available as a default export. I tried to keep it as close as possible as reflected in the source code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@typescript-bot

typescript-bot commented Apr 29, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

@perrin4869 Thank you for submitting this PR!

This is a live comment that I will keep updated.

1 package in this PR

  • pg — on npm, on unpkg

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": 72649,
  "author": "perrin4869",
  "headCommitOid": "61138f1bd1b3fdcad8efdd895374d0489a1bf13c",
  "mergeBaseOid": "8c2858ff35ca248b88fac813e501b568b1a422b7",
  "lastPushDate": "2025-04-29T15:55:21.000Z",
  "lastActivityDate": "2025-05-06T19:24:10.000Z",
  "mergeOfferDate": "2025-05-06T19:23:27.000Z",
  "mergeRequestDate": "2025-05-06T19:24:10.000Z",
  "mergeRequestUser": "perrin4869",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "pg",
      "kind": "edit",
      "files": [
        {
          "path": "types/pg/index.d.mts",
          "kind": "definition"
        },
        {
          "path": "types/pg/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/pg/package.json",
          "kind": "package-meta-ok"
        },
        {
          "path": "types/pg/pg-tests.mts",
          "kind": "test"
        },
        {
          "path": "types/pg/tsconfig.json",
          "kind": "package-meta-ok"
        }
      ],
      "owners": [
        "pspeter3"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "gabritto",
      "date": "2025-05-06T19:22:48.000Z",
      "isMaintainer": true
    }
  ],
  "mainBotCommentID": 2839428422,
  "ciResult": "pass"
}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot typescript-bot added the Critical package label Apr 29, 2025
@typescript-bot

typescript-bot commented Apr 29, 2025

Copy link
Copy Markdown
Contributor

🔔 @pspeter3 — 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot typescript-bot moved this to Waiting for Code Reviews in Pull Request Status Board Apr 29, 2025
@typescript-bot typescript-bot added this to Pull Request Status Board Apr 29, 2025
@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Apr 29, 2025
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in Pull Request Status Board Apr 29, 2025
@typescript-bot

typescript-bot commented Apr 29, 2025

Copy link
Copy Markdown
Contributor

@perrin4869 The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

Note: builds that are failing do not end up on the list of PRs for the DT maintainers to review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Apr 29, 2025
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in Pull Request Status Board Apr 29, 2025
@perrin4869
perrin4869 force-pushed the feat/pg/add-default-export branch from d1e3629 to 82ed082 Compare April 29, 2025 16:43
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board Apr 29, 2025
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Code Reviews in Pull Request Status Board Apr 29, 2025
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board Apr 29, 2025
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Code Reviews in Pull Request Status Board Apr 29, 2025
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board Apr 29, 2025
@typescript-bot typescript-bot added the Where is GH Actions? GH Actions didn't give a response to this PR label Apr 30, 2025
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Other in Pull Request Status Board Apr 30, 2025
@typescript-bot typescript-bot removed the Where is GH Actions? GH Actions didn't give a response to this PR label Apr 30, 2025
@typescript-bot typescript-bot moved this from Other to Needs Maintainer Review in Pull Request Status Board Apr 30, 2025
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Code Reviews in Pull Request Status Board Apr 30, 2025
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board Apr 30, 2025
@typescript-bot typescript-bot added the Has Merge Conflict This PR can't be merged because it has a merge conflict. The author needs to update it. label May 6, 2025
@typescript-bot

typescript-bot commented May 6, 2025

Copy link
Copy Markdown
Contributor

@perrin4869 Unfortunately, this pull request currently has a merge conflict 😥. Please update your PR branch to be up-to-date with respect to master. Have a nice day!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot typescript-bot moved this from Needs Maintainer Review to Needs Author Action in Pull Request Status Board May 6, 2025
perrin4869 added 5 commits May 6, 2025 14:45
@perrin4869
feat(pg): add default export
2411d57
@perrin4869
fix
0942c12
@perrin4869
format
98e4e94
@perrin4869
include mts tests
bbf3091
@perrin4869
remove redundant import
1314c7a
@perrin4869
fix: types
9961594
@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label May 6, 2025
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in Pull Request Status Board May 6, 2025
@perrin4869
fix: format
61138f1
@typescript-bot

typescript-bot commented May 6, 2025

Copy link
Copy Markdown
Contributor

@gabritto 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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board May 6, 2025
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Code Reviews in Pull Request Status Board May 6, 2025
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board May 6, 2025
@perrin4869
perrin4869 requested a review from gabritto May 6, 2025 19:15
gabritto
gabritto approved these changes May 6, 2025
View reviewed changes
@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner labels May 6, 2025
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Author to Merge in Pull Request Status Board May 6, 2025
@perrin4869

perrin4869 commented May 6, 2025

Copy link
Copy Markdown
Contributor Author

Ready to merge

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in Pull Request Status Board May 6, 2025
@typescript-bot
typescript-bot merged commit e8c8bd6 into DefinitelyTyped:master May 6, 2025
This was referenced May 7, 2025
fix(pg): named exports #72710
Merged
fix(types): align new esm imports MatteoGioioso/serverless-pg#94
Merged
B4nan
B4nan reviewed May 7, 2025
View reviewed changes
Comment thread types/pg/index.d.mts
export const escapeLiteral: typeof pg.escapeLiteral;
export const Result: typeof pg.Result;

export { TypeOverrides };

@B4nan B4nan May 7, 2025

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

this export should be in the CJS types too

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@perrin4869 perrin4869 May 7, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

good point, will be fixed in #72710

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@B4nan B4nan May 7, 2025

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

amazing, thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ritschwumm

ritschwumm commented May 7, 2025

Copy link
Copy Markdown

something seems to be wrong after this with @types/pg 8.15.0 where version 8.12.0 worked fine:

  • i have an ESM package with "module": "ESNext", "moduleResolution": "bundler",
  • my code uses import pg from "pg"; and accesses all types with a prefix like so: pg.Pool
  • everywhere i do it get a error TS2503: Cannot find namespace 'pg'.

this may be related to the "resolution failed" errors in https://arethetypeswrong.github.io/?p=pg

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@perrin4869

perrin4869 commented May 7, 2025

Copy link
Copy Markdown
Contributor Author

package.json fails to resolve due to it not being exported upstream, it wouldn't be related to these changes I think.
do you have type: module in your package.json? I think the types are correct but since now we have a hybrid module, you need to be more specific how to resolve the packages...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ritschwumm

ritschwumm commented May 7, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

sorry i left that out; yes, i do have "type": "module", in my package.json. anything else you might want to know? if i have to, i can try to make a minimal reproducer, but as that's some work i'd of course like to avoid it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@otaviojacobi

otaviojacobi commented May 7, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Hello, thanks for the work but I am also facing the same issue, here is a clean repro (using ESM):

import pg from 'pg';

let pool: pg.Pool;

const initPool = () => {
    pool = new pg.Pool();
}

This complains of pg namespace not being found. If I do something like for Pg typing:

import type * as PgTypes from 'pg';
let pool: PgTypes.Pool;

This also fails with 'PgTypes.Pool' refers to a value, but is being used as a type here. Did you mean 'typeof PgTypes.Pool'?ts(2749)

And finally if I do try to use let pool: typeof PgTypes.Pool; I also get an error as Type 'Pool' is missing the following properties from type 'typeof Pool

Where the previous (first version) was working fine on 8.12

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@perrin4869

perrin4869 commented May 7, 2025

Copy link
Copy Markdown
Contributor Author

@otaviojacobi that specific issue will be solved by my followup, #72710 sorry about that!
declaring a variable let pool: pg.Pool; is broken because I didn't write the exports correctly
@ritschwumm if your usage is similar to that one, it should be fixed once #72710 is merged, sorry about that!

otaviojacobi reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@otaviojacobi

otaviojacobi commented May 7, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Thanks @perrin4869 !

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ritschwumm

ritschwumm commented May 7, 2025

Copy link
Copy Markdown

@perrin4869 thanks, i'll check as soon as it's available

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@otaviojacobi otaviojacobi mentioned this pull request May 7, 2025
Delete files with pine tasks when it is available balena-io/pinejs#896
Merged
frankdejonge
frankdejonge reviewed May 8, 2025
View reviewed changes
Comment thread types/pg/index.d.mts
export type * from "./index.d.ts";

export const defaults: typeof pg.defaults;
export const Client: typeof pg.Client;

@frankdejonge frankdejonge May 8, 2025

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The const exports caused a regression in my project. Before, a type could be imported using import type {Client} from 'pg'. After this was released my project broke because it's with the following error:

error TS2749: 'Client' refers to a value, but is being used as a type here. Did you mean 'typeof Client'?

I've worked around it by importing the full pg namespace, but I thought I'd inform you of this regression.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@perrin4869 perrin4869 May 8, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

should be fixed by #72710, sorry about that!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@frankdejonge frankdejonge May 8, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Correction, that workaround does not work. I cannot import just the types anymore. Quite an inconvenient regression.

In addition to the error described above, when importing as import type pg from 'pg', you get the error: Cannot find namespace 'pg'.. This is also true for not importing it as a type.

EDIT: I see the other comments report this too, feel free to ignore.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@WolfyUK WolfyUK mentioned this pull request May 9, 2025
New exports break TypeScript "bundler" compilation brianc/node-postgres#3457
Closed
@typescript-bot typescript-bot removed this from Pull Request Status Board May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gabritto gabritto gabritto approved these changes
+2 more reviewers
@frankdejonge frankdejonge frankdejonge left review comments
@B4nan B4nan B4nan left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

Critical package Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@perrin4869 @typescript-bot @ritschwumm @otaviojacobi @frankdejonge @B4nan @gabritto
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.