Skip to content
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

Changes to imported ts files not detected by VSCode #626

Closed
3 tasks done
shasderias opened this issue Jan 9, 2018 · 2 comments
Closed
3 tasks done

Changes to imported ts files not detected by VSCode #626

shasderias opened this issue Jan 9, 2018 · 2 comments

Comments

@shasderias
Copy link

shasderias commented Jan 9, 2018

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: Windows
  • Vetur version: 0.11.5
  • VS Code version: 1.19.1

Problem

Error message from Panel -> Output -> Vue Language Server:
None. I just see:
vetur initialized

Reproducible Case

  1. Run:
vue init vuejs-templates/webpack#pull/797/head vue-ts-bug

With the following options:

? Project name vue-ts-bug
? Project description A Vue.js project
? Author <snip>
? Vue build standalone
? Use TypeScript as default language? Yes
? Install vue-router? Yes
? Use ESLint to lint your code? No
? Set up unit tests No
? Setup e2e tests with Nightwatch? No
? Should we run `npm install` for you after the project has been created? (recommended) npm
  1. In VSCode, File -> Open Folder -> [Select vue-ts-bug folder]

  2. Create and save:
    src/apple.ts

export const Apple = "Apple";
  1. Edit and save:
    src/components/HelloWorld.vue
<script lang="ts">
import Vue from 'vue'
import { Apple } from "../apple";

<snip>
  1. Edit and save:
    src/apple.ts
export const Apple2 = "Apple";
  1. Edit and save:
    src/components/HelloWorld.vue
<script lang="ts">
import Vue from 'vue'
import { Apple2 } from "../apple";

<snip>

Expected to see:
No errors

Instead saw:
VSCode marks this line:

import { Apple2 } from "../apple";

as having the error:
Module '"c:/path-to-vue-ts-bug/src/apple` has no exported member 'Apple2'"

Restarting VSCode causes VSCode to pick up the changes from apple.ts, i.e. error goes away. Making further changes to apple.ts (e.g. renaming Apple2 back to Apple) will cause the error to occur again.

Filing an issue here as this doesn't occur when apple.ts is imported from another .ts file. e.g. if the following line is added to index.ts:

import { Apple2 } from './apple';

VSCode detects changes made to apple.ts and works as expected.

The issue is purely cosmetic, i.e. even if VSCode marks the import statement as an error, the compiled code works properly (assuming the apple.ts export is consistent with the import of course). However, until VSCode is restarted, you lose all auto-completion for the changes VSCode doesn't know about.

Apologies if this is not an error with Vetur and should be filed somewhere else.

@HerringtonDarkholme
Copy link
Member

It is already known.
#355

I want to support it but I'm too busy with my day job 😢

@shasderias
Copy link
Author

Ah, looks like my searching skills failed me. Spent all day trawling through issues and didn't find #355.

Thanks for responding and your contributions to Vue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants