You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above code snippet, the register function from tsconfig-paths expects baseUrl to be a string. When the baseUrl compiler option is not set, the error below occurs.
Stack trace
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at new NodeError (node:internal/errors:399:5)
at validateString (node:internal/validators:163:11)
at Object.isAbsolute (node:path:1157:5)
at configLoader (/Users/ianyong/<redacted>/node_modules/.pnpm/tsconfig-paths@4.1.0/node_modules/tsconfig-paths/src/config-loader.ts:50:34)
at Object.register (/Users/ianyong/<redacted>/node_modules/.pnpm/tsconfig-paths@4.1.0/node_modules/tsconfig-paths/src/register.ts:79:42)
at Function.registerTsNode (/Users/ianyong/<redacted>/node_modules/.pnpm/@mikro-orm+core@5.7.12_@mikro-orm+migrations@5.7.12_@mikro-orm+postgresql@5.7.12_@mikro-orm+seeder@5.7.12/node_modules/@mikro-orm/core/utils/ConfigurationLoader.js:118:71)
at Function.configure (/Users/ianyong/<redacted>/node_modules/.pnpm/@mikro-orm+cli@5.7.12_@mikro-orm+migrations@5.7.12_@mikro-orm+postgresql@5.7.12_@mikro-orm+seeder@5.7.12_pg@8.11.0/node_modules/@mikro-orm/cli/CLIConfigurator.js:29:61)
at async /Users/ianyong/<redacted>/node_modules/.pnpm/@mikro-orm+cli@5.7.12_@mikro-orm+migrations@5.7.12_@mikro-orm+postgresql@5.7.12_@mikro-orm+seeder@5.7.12_pg@8.11.0/node_modules/@mikro-orm/cli/cli.js:13:18 {
code: 'ERR_INVALID_ARG_TYPE'
}
To Reproduce
Steps to reproduce the behavior:
Enable the useTsNode flag in package.json.
Set the paths compiler option but not the baseUrl compiler option in tsconfig.json.
Run any command that makes use of ts-node, such as mikro-orm migration:fresh.
Expected behavior
When baseUrl is not specified, it should default to '.' instead of throwing an error.
Additional context
The expected behaviour described above is effectively the same approach taken by the tsconfig-paths library itself when reading directly from a tsconfig.json file which does not have the baseUrl compiler option specified (dividab/tsconfig-paths#208). The reason why I believe this issue should be fixed within MikroORM and not upstream is because in this case, MikroORM is not respecting the interface of the register method by passing in an argument of type string | undefined when string is expected.
Versions
Dependency
Version
node
18.16.0
typescript
5.0.3
mikro-orm
5.7.12
The text was updated successfully, but these errors were encountered:
Describe the bug
Since TypeScript 4.1, the
paths
compiler option can be used without thebaseUrl
compiler option. However, theConfigurationLoader
assumes that thebaseUrl
option is set when thepaths
option is set when MikroORM'suseTsNode
flag inpackage.json
is set totrue
:mikro-orm/packages/core/src/utils/ConfigurationLoader.ts
Lines 135 to 148 in b0ecd21
In the above code snippet, the
register
function fromtsconfig-paths
expectsbaseUrl
to be astring
. When thebaseUrl
compiler option is not set, the error below occurs.Stack trace
To Reproduce
Steps to reproduce the behavior:
useTsNode
flag inpackage.json
.paths
compiler option but not thebaseUrl
compiler option intsconfig.json
.ts-node
, such asmikro-orm migration:fresh
.Expected behavior
When
baseUrl
is not specified, it should default to'.'
instead of throwing an error.Additional context
The expected behaviour described above is effectively the same approach taken by the
tsconfig-paths
library itself when reading directly from atsconfig.json
file which does not have thebaseUrl
compiler option specified (dividab/tsconfig-paths#208). The reason why I believe this issue should be fixed within MikroORM and not upstream is because in this case, MikroORM is not respecting the interface of theregister
method by passing in an argument of typestring | undefined
whenstring
is expected.Versions
The text was updated successfully, but these errors were encountered: