Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add instructions for type-only imports #2432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jmcooper wants to merge 1 commit into vuejs:main
base: main
Choose a base branch
Loading
from jmcooper:patch-1

Conversation

Copy link

@jmcooper jmcooper commented Jul 6, 2023
edited
Loading

Description of Problem

Because Vue uses isolatedModules, it is necessary to use type-only import syntax when importing types. Discovering the resolution for this edge case is difficult when first beginning to work with TypeScript and Vue/Vite.

This is easy to replicate by creating an app with create-vue and selectihg the typescript option. Then, export an interface from a .ts file and import it and try to use it as a type in a component. When you run npm run type-check you will see the error. Here is a sample repo that duplicates the problem with a new create-vue app: https://github.com/jmcooper/create-vue-ts-repro

Reproducing the Problem

See instructions above to repro from scratch. Or:

  1. Clone https://github.com/jmcooper/create-vue-ts-repro
  2. npm install
  3. Run npm run type-check

Proposed Solution

Update the documentation as proposed to make it clear this is an expected behavior and how to resolve it.

Additional Information

Sample repo to replicate the problem: https://github.com/jmcooper/create-vue-ts-repro

Because Vue uses isolatedModules, it is necessary to used type-only import syntax when importing types. Discovering the resolution for this edge case is difficult when first beginning to work with TypeScript and Vue/Vite.
Copy link

netlify bot commented Jul 6, 2023
edited
Loading

Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit 297d6f3
🔍 Latest deploy log https://app.netlify.com/sites/vuejs/deploys/64a71025dcff850008ac5e41
😎 Deploy Preview https://deploy-preview-2432--vuejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /