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

Intellisense is not working when .d.ts file contains import statement #1098

Closed
3 tasks done
nandin-borjigin opened this issue Feb 16, 2019 · 4 comments
Closed
3 tasks done

Comments

@nandin-borjigin
Copy link

nandin-borjigin commented Feb 16, 2019

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

Info

  • Platform: macOS
  • Vetur version: 0.15.1
  • VS Code version: 1.31.1

Problem

screen shot 2019-02-17 at 2 54 02 am

Intellisense is not working in certain case (I suppose it is related to import statement in .d.ts file)

If you're interested, the "1" after error icon in the status bar is about the incomplete statement a. in index.ts.

screenshot of this irrelavant error

screen shot 2019-02-17 at 3 32 03 am

Reproducible Case

Four files for reproduction:

lib/foo.d.ts
export type Foo = { prop: number }
lib/index.d.ts
export const foo: import('./foo').Foo
index.ts
import { foo } from './lib'

const a = foo
index.vue
<script lang="ts">
import { foo } from './lib'

const a = foo
</script>


You may like to clone this reproduction repo, or, generate those files with following script

IMPORTANT: RUN THIS SCRIPT IN AN EMPTY DIRECTORY

mkdir lib
echo "export type Foo = { prop: number }" > lib/foo.d.ts
echo "export const foo: import('./foo').Foo" > lib/index.d.ts
echo -e "import { foo } from './lib'\nconst a = foo" > index.ts
echo -e "<script lang="ts">\nimport { foo } from './lib'\nconst a = foo\n</script>" > index.vue

Steps

  1. Hover over the a variable in index.ts file. There would be a popover widget indicating a is of type Foo
  2. Hover over the a variable in index.vue file. There would be a popover widget indication a is of type any, which is WRONG.
  3. In index.ts file, type in a., then a popover shows and says there is a prop property of type number under variable a
  4. Repeat step 3 inside index.vue and there would be no popover.
@nandin-borjigin
Copy link
Author

In addition, intellisense is working even in a .js file.

@nandin-borjigin
Copy link
Author

After digging into the source code, I found that the language server (i.e. VLS) is using [email protected]. And if I switch the typescript.tsdk of the vscode to a local typescript of version 2.8.4, then same failure would reproduce in *.ts file.

image

@nandin-borjigin
Copy link
Author

After upgrading typescript dependency to ^3.3.0, fixing a few typescript-api-change related errors, and adopting the solution in #1045, it's now working in my machine.

I also tested my fork in a standalnoe travis CI environment, but, sadly, it fails one test on linux (while passing all tests on macOS). I cannot proceed any further as I don't have a linux machine at my hand .

I'm leaving this issue open just in case anyone else would come to similar problem.

@octref
Copy link
Member

octref commented Mar 14, 2019

Thanks. This will be resolved after we allow you to use a more recent version of TS with #682 and maybe upgrading Vetur to depend on a more recent TS.

@octref octref closed this as completed Mar 14, 2019
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

No branches or pull requests

2 participants