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
So with this config IDE already doesn't give error. tsc command also works fine.
In my tools/codegen/package.json i have "bin":"index.mts"
So after install I 'm able to run npx codegen from tools/codegen
However if I run it from the root of the monorepo it seems that ts-node is not smart enough to determine what is the base folder for executed file. So command npx codegen from the root level triggers top-level await TypeScript error which occurs without tsconfig.json
To be able to run npx codegen from root level i use "workspaces" : "tools/*" in my root package.json
Expected behavior
I expect that ts-node should understand from where it is called. Indeed node is called with some path and that path can be used as a base path for config determination.
It should not matter from where I call my npx codegen command - it should work similarly becase config should be linked to the executed file and not to the folder from where I run.
In my case I don't have tsconfig.json - but in more complicated case I might have one but with different set up.
Current behavior
Let's say I have a subpackage in my workspace which I want to use a module .
So i have a folder like
tools/codegen
with file like index.mts with a content likeSo without tsconfig.json tsc will not work. So let's add
tools/codegen/tsconfig.json
So with this config IDE already doesn't give error. tsc command also works fine.
In my
tools/codegen/package.json
i have"bin":"index.mts"
So after install I 'm able to run
npx codegen
from tools/codegenHowever if I run it from the root of the monorepo it seems that ts-node is not smart enough to determine what is the base folder for executed file. So command
npx codegen
from the root level triggers top-level await TypeScript error which occurs without tsconfig.jsonTo be able to run
npx codegen
from root level i use "workspaces" : "tools/*" in my root package.jsonExpected behavior
I expect that ts-node should understand from where it is called. Indeed node is called with some path and that path can be used as a base path for config determination.
It should not matter from where I call my
npx codegen
command - it should work similarly becase config should be linked to the executed file and not to the folder from where I run.In my case I don't have tsconfig.json - but in more complicated case I might have one but with different set up.
Example
I've prepared a sample project showing this behavior https://github.com/ThePlenkov/ts-config-top-level-await-issue
Thanks!
The text was updated successfully, but these errors were encountered: