question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VSCode "auto import" of ESM module broken in 2.6.11 with umd namespace

See original GitHub issue

Version

2.6.11

Reproduction link

https://imgur.com/a/RxJz6fT

Steps to reproduce

Since the 2.6.11 my IDE (VSCode) now suggest me import Vue from the ‘vue/types/umd’ namespace instead of the ESModule ‘vue’

I’m using Vue 2.6.11 Vue-CLI 4.1.0 VScode 1.41.1 Typescript 3.7.4

What is expected?

Prior 2.6.11, VScode was suggesting to import Vue from 'vue'

What is actually happening?

VSCode is suggesting me to import Vue from 'vue/types/umd' see screenshot


maybe it’s releated to https://github.com/vuejs/vue/pull/9912 ?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
chuckmahcommented, Jan 16, 2020

@octref from you example if you add Typescript you will have the auto-import suggesting by clicking on the 💡 from VSCode.

here’s how i reproduced it using minimal deps (not the vue-cli)

mkdir foo
cd foo
yarn add typescript vue vue-property-decorator
npx tsc --init --module "ES6" --lib "ES6" --target "ES6" --types "vue" --moduleResolution "Node"
touch TestVue.ts
code .

inside TestVue.ts

const component:Component = Vue.extend({});

The named import work i still get the suggestion to import from ‘vue’

NamedImport

But the default import do not appear DefaultImport

If i revert back to 2.6.10 i get the correct suggestion from the ‘vue’ DefaultImport2610

Maybe it’s a TSServer issue 😕 … but because some of my dev on my team just use the suggested import regardless, i had to revert back to 2.6.10

1reaction
posvacommented, Jan 14, 2020

You should import it from vue-property-decorator like import { Component, Vue } from 'vue-property-decorator'

It looks like Vue is automatically imported within VSCode as creating an empty vue file already allows you to use Vue with correct typings, so I imagine it would make sense for the IDE to not be able to import automatically. I don’t know if this is something we can improve. @octref do you know if this is possible to change here or somewhere else?

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code auto import using require instead of importing ES ...
Anytime I create a JS file, it is considered a CommoJS Module instead of an ES Module. And if I try to import...
Read more >
Auto import | WebStorm Documentation - JetBrains
Basic procedures to create and optimize imports in WebStorm. Learn more how to import the missing import or XML namespace.
Read more >
Visual Studio Code Extension - Auto Import - YouTube
Visual Studio Code Extension - Auto ImportIn this video, we take a look at the Auto Import extension within Visual Studio Code.
Read more >
Auto Import | PHP Tools for Visual Studio Documentation
Importing classes, functions, and constants from outside the namespace.
Read more >
PHP Namespace Resolver - Visual Studio Marketplace
Extension for Visual Studio Code - Import and expand php namespaces.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found