unplugin / unplugin/unplugin-auto-import
Type errors with exported types or variables in .ts files
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Hi,
In a project I want to build a library with its types, therefore I use the vue-tsc --project command to build types separately.
In this types building step, I get errors if I import types from vue in a .ts file and use them in exported types or variables.
Example in a .ts file:
export type NumberRef = Ref<number>
Triggers the error: error TS4081: Exported type alias 'NumberRef' has or is using private name 'Ref'.
Other example:
export const count: Ref<number> = ref(1)
Triggers the error: error TS4025: Exported variable 'count' has or is using private name 'Ref'.
I provided a minimal reproduction based on vitesse, with this commit reflecting what I'm describing here, happening with pnpm build:types or pnpm build commands.
Reproduction
https://github.com/pascalgermain/vitesse/commit/fc47dec9a5ecbcbb139a66843ced975eba32e1a6
System Info
System:
OS: macOS 14.1.2
CPU: (10) arm64 Apple M2 Pro
Memory: 453.52 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.4.0 - ~/.nvm/versions/node/v21.4.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v21.4.0/bin/yarn
npm: 10.2.5 - ~/.nvm/versions/node/v21.4.0/bin/npm
pnpm: 8.12.0 - ~/.nvm/versions/node/v21.4.0/bin/pnpm
bun: 1.0.17 - /opt/homebrew/bin/bun
Browsers:
Brave Browser: 120.1.61.100
Chrome: 120.0.6099.71
Safari: 17.1.2
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- The provided reproduction is a minimal reproducible of the bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked vitesse reproduction commit and run pnpm build:types or pnpm build to confirm the TS4081 and TS4025 errors. Trace how vue-tsc --project handles exported types and variables in .ts files that use imported Vue types. Done means the minimal reproduction builds its types without these private-name errors and the regression is covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100