Skip to content

Error with pg-protocol and @types/pg during typescript build: Cannot find module 'pg-protocol/dist/messages' #3435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
seisenberg opened this issue Apr 23, 2025 · 3 comments

Comments

@seisenberg
Copy link

Hi,

Also reporting another similar error that is popping up from the ESM update for pg-protocol with the @types/pg definitions.

node_modules/@types/pg/index.d.ts:6:31 - error TS2307: Cannot find module 'pg-protocol/dist/messages' or its corresponding type declarations.
import { NoticeMessage } from "pg-protocol/dist/messages";

Thanks

@brianc
Copy link
Owner

brianc commented Apr 23, 2025

Thanks...i'll make sure all the pg-protocol sub items are importable and exported properly in both commonjs and esm w/ some tests here.

@brianc
Copy link
Owner

brianc commented Apr 23, 2025

@seisenberg I don't fully understand the issue...it's slightly sparse on details & if it's a type-def thing I'm not 100% sure exactly, but this PR does increase the visibility of what can be imported by sub-paths at this part of the PR here which should allow for visibility when those paths are imported. I had no idea how many sub-paths and files were being directly pulled in. 🤕

@seisenberg
Copy link
Author

seisenberg commented Apr 23, 2025

Thanks for the quick action @brianc !

This is still showing as a problem on my side, it's in relation to how typescript is resolving the module dependencies.

https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution-for-libraries
All around the use here
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pg/index.d.ts#L6
since it lacks a file extension.

Please let me know how else I can help, I don't think its directly related to my projects tsconfig but sharing in case it is.

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "module": "NodeNext",
    "sourceMap": true,
    "outDir": "./build",
    "target": "ESNext",
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    },
    "types": ["node","vite/client"],
    "moduleResolution": "NodeNext",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "strictNullChecks": true,
    "skipLibCheck": false,
    "forceConsistentCasingInFileNames": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
  },
  "exclude": [
    "node_modules"
  ],
  "include": [
    "src"
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants