Skip to content

Use 'import type' in TypeScript examples#1656

Merged
NataliaTepluhina merged 1 commit into
vuejs:mainfrom
skirtles-code:type-modifier
Apr 13, 2022
Merged

Use 'import type' in TypeScript examples#1656
NataliaTepluhina merged 1 commit into
vuejs:mainfrom
skirtles-code:type-modifier

Conversation

@skirtles-code

Copy link
Copy Markdown
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

netlify Bot commented Apr 10, 2022

Copy link
Copy Markdown

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.

@dammy001 dammy001 left a comment

Copy link
Copy Markdown
Contributor

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