Closed 4leite closed 1 month ago
Workaround is to add empty imports per the error messages, eg:
import type {} from "@uploadthing/shared"
import type {} from "next/server"
edit: added type annotation per suggestion below
yea i think this is the only way.
this is an issue in the "lazyness" of TypeScript where you have nested packages it doesn't dig deep enough to find those types automatically for you.
what i have found is that using something other than pnpm solves this sometimes, as the nested node_modules/.pnpm
seems to make it even harder for typescript to automatically find the types...
you can change it to import type * as UTShared from "@uploadthing/shared"
so that the imports aren't present in the output javascript though.
from my understanding this is also getting improved in typescript 5.5: https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#consulting-packagejson-dependencies-for-declaration-file-generation
Nice, I mostly raised the bug to document the workaround and see if there were any better solutions.
Yea - it's unfortunate we have this limitation in TypeScript right now. It's like this for a lot of libraries that has framework agnostic core packages that are not explicitely installed by the end user.
I reproduced it in ReactQuery, NextAuth and we tried extracting a bunch of core logic in trpc and ran into it there too.
Hopefully it will be a thing of the past when 5.5 comes, but in the meantime using those "fake imports" is the way i think...
This issue has been automatically marked as stale because it has not had any activity for 10 days. It will be closed in 5 days if no further activity occurs.
This issue has been closed because it has not had any activity for 5 days since being marked as stale.
Provide environment information
Describe the bug
Getting:
I'm building a library that is then consumed downstream, so declaration files are a requirement.
Link to reproduction
https://github.com/4leite/ut-declaration
To reproduce
Additional information
192 was closed (maybe fixed?)
252 was closed (superseded by #272)
272 was closed (won't fix)
I've indicated I'm down to submit a PR, but looking at the talented folks who have already thrown their hands up, I'm not sure I've got any better suggestions.
๐จโ๐งโ๐ฆ Contributing
Code of Conduct