@@ -16,7 +16,9 @@ import { cwd } from 'node:process';
1616import { pathToFileURL } from 'node:url' ;
1717import { format } from 'node:util' ;
1818import type { ClientConfig } from 'pg' ;
19- // This needs to be imported with .js extension, otherwise it will fail in esm
19+ import type ConnectionParametersType from 'pg/lib/connection-parameters' ;
20+ // TODO causes tests to fail when `.js` is removed
21+ // @ts -expect-error type exports from @types/pg doesn't match importing
2022import ConnectionParameters from 'pg/lib/connection-parameters.js' ;
2123import yargs from 'yargs/yargs' ;
2224import type { RunnerOption } from '../src' ;
@@ -274,8 +276,11 @@ if (dotenv) {
274276
275277let MIGRATIONS_DIR = argv [ migrationsDirArg ] ;
276278let USE_GLOB = argv [ useGlobArg ] ;
277- let DB_CONNECTION : string | ConnectionParameters | ClientConfig | undefined =
278- process . env [ argv [ databaseUrlVarArg ] ] ;
279+ let DB_CONNECTION :
280+ | string
281+ | ConnectionParametersType
282+ | ClientConfig
283+ | undefined = process . env [ argv [ databaseUrlVarArg ] ] ;
279284let IGNORE_PATTERN = argv [ ignorePatternArg ] ;
280285let SCHEMA : string | string [ ] | undefined = argv [ schemaArg ] ;
281286let CREATE_SCHEMA = argv [ createSchemaArg ] ;
@@ -436,7 +441,7 @@ function readJson(json: unknown): void {
436441 DB_CONNECTION ,
437442 databaseUrlVarArg ,
438443 json ,
439- ( val ) : val is string | ConnectionParameters | ClientConfig =>
444+ ( val ) : val is string | ConnectionParametersType | ClientConfig =>
440445 typeof val === 'string' || typeof val === 'object'
441446 ) ;
442447 tsconfigPath = applyIf ( tsconfigPath , tsconfigArg , json , isString ) ;
@@ -456,7 +461,7 @@ function readJson(json: unknown): void {
456461 } ;
457462 }
458463 } else {
459- DB_CONNECTION ??= json as string | ConnectionParameters | ClientConfig;
464+ DB_CONNECTION ??= json as string | ConnectionParametersType | ClientConfig;
460465 }
461466}
462467
@@ -484,8 +489,7 @@ if (configFileName) {
484489await readTsconfig ( ) ;
485490
486491if ( useTsx ) {
487- const tsx =
488- await tryImport < typeof import ( 'tsx/dist/esm/api/index.mjs' ) > ( 'tsx/esm' ) ;
492+ const tsx = await tryImport < typeof import ( 'tsx/esm/api' ) > ( 'tsx/esm' ) ;
489493 if ( ! tsx ) {
490494 console . error ( "For TSX support, please install 'tsx' module" ) ;
491495 }
0 commit comments