inferred type of '...' cannot be named without a reference to '...'
I found this in an old question from about a year ago when running into this issue in the process of adding type safety to Waku (new react framework by dai-shi) link to error
I plan to use type annotation to unblock this per the recommendation here
I wanted to re-ask this though, in case anyone here has come across a better way to fix this issue with a pnpm project over the course of the past year. @ArkDavid is this still something you see from time to time?
Edit: Maybe this question is better suited for twitter?
14 Replies
Disregard this ^
I just read to the helpful comment in that ts thread 🤦♂️ https://github.com/microsoft/TypeScript/issues/42873#issuecomment-2065572017
GitHub
The inferred type of "X" cannot be named without a reference to "Y"...
Bug Report 🔎 Search Terms inferred type cannot be named, symlink node_modules 🕗 Version & Regression Information I'm verifying the problem on the [email protected]. I've not tried older ...
Would be interested to know what the specific error you got was
It shows in this failed CI job here: https://github.com/dai-shi/waku/actions/runs/10761950734/job/29841704519?pr=854
Is this related to ArkType or just a general TS question?
general ts question... sorry. I kinda just figured this would be a good place to check for an error as weird as this one 😅
Ahh okay yeah I've dealt with this also so I just wanted to make sure it wasn't something new internally.
Generally https://discord.com/channels/957797212103016458/1114601623285678192 is probably a good place to ask broader TS questions, although not a big deal at all. You just had me worried for a sec 😛
haha sorry for the scare! definitely good to know that for the future. I appreciate you taking a minute to respond here too 🙂
No problem! Happy to help
Well
I didn't really help TBH lol
But if I can I will 😛
Your old message did! haha I just didn't read it closely enough the first time
Oh good! I didn't realize you were linking to an old answer of mine haha
yep! it was re-assuring to see that as validation that I wasn't mis-configuring something and seems to be a somewhat known issue.
Hi, so how did you fix it in the end?
For me I did
export * from 'arktype'
in that package's type file, but that makes it very slow to buildThis was the file where the error was occuring. It seems like this will be an internal issue only from what I can tell, so I just added the type annotation as was recommended by that github issue and the error message.
It's neat to know that
export *
could also work, but it definitely does sound slower than I'd like.
It seems worth mentioning that this widens the type of
router
in this case.
In other cases I use the inference to collect the types of the paths
created from the results of createPage
which get returned in a list from createPages
: example source code
So for this file where I annotated the type of router, I lose that inference and my paths
for it have to just revert to any string.
In this case that is acceptable, but if this came up after publishing the types to an end user of the library I would need to find a better fix.
afaict though, this is just related to pnpm linking within the scope of the monorepo I am developing in, so it shouldn't be in issue after publishing.