Skip to content

Use 'import type' in TypeScript examples #1656

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

Merged
merged 1 commit into from
Apr 13, 2022

Conversation

skirtles-code
Copy link
Contributor

This PR attempts to address the problem raised in #1616.

The TS settings currently used by npm init vue require the use of the type modifier when importing types. So the following won't work:

import { ref, Ref } from 'vue'

This could be fixed using:

import { ref, type Ref } from 'vue'

However, this won't currently work in the SFC Playground. Details at vuejs/repl#28.

The only syntax that seems to work in both cases is:

import { ref } from 'vue'
import type { Ref } from 'vue'

I'm not convinced this is ideal either. While it does work in all cases, I feel this is probably the least likely of the 3 options to be used in a real project.

In this PR I've switched the examples to use that last syntax. There aren't many examples that are affected. Once the Playground supports the second syntax I'd be inclined to switch to that instead.

@netlify
Copy link

netlify bot commented Apr 10, 2022

Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit a89c9ec
🔍 Latest deploy log https://app.netlify.com/sites/vuejs/deploys/6252d5602aeada00094b0c24
😎 Deploy Preview https://deploy-preview-1656--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 settings.

Copy link
Contributor

@dammy001 dammy001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🤌🏾

@NataliaTepluhina NataliaTepluhina merged commit 4fc8ad3 into vuejs:main Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants