pg-typed does not generate explicit file extensions compatible with `Node16`/`NodeNext` module resolution
juho opened this issue · 4 comments
I've tried moving to Node16
/NodeNext
module resolution to take advantage of package exports and pg-typed is causing a bit of headache as it does not add the .js
to the imported filenames when generating code. Would adding these be a problem?
../db/dist/__generated__/user_session.d.ts:7:21 - error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './account.js'?
7 import Account from './account';
~~~~~~~~~~~
I think the issue here is that it would break older versions of TypeScript. It's really important not to break this for existing users. Do you have a link to the docs on this new module resolution stuff? It seems like a super bad move from TypeScript to mess with this.
I believe these are the Typescript docs in question?
https://www.typescriptlang.org/docs/handbook/esm-node.html
I have enjoyed working with so far, and this is a bummer. Hopeful there is a fix for this.
I managed to fix this by adding this into the generated folder.
{ "name": "db-schema", "type": "commonjs" }
and use tables.default<DatabaseSchema.default>
in the file where i'm using it.