microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.87k stars 29.51k forks source link

Editor doesn't detect typings in "typings/globals" #10042

Closed MartinHaeusler closed 8 years ago

MartinHaeusler commented 8 years ago

Steps to Reproduce:

  1. Create a regular typescript project with the files provided below.
  2. Remove the ".txt" file endings to make them json files again (github doesn't allow .json endings as attachments, sorry)
  3. Run "npm install"
  4. Run "typings install"
  5. Create a *.ts file that imports the 'react' module
  6. Look at the typescript error you are getting from the editor.

In short: any typings file that ends up in "typings/globals" will NOT be detected by the editor. However, when running through the typscript compiler, e.g. via webpack, everything's fine. It's only the editor, which is really annoying.

tsconfig.json.txt typings.json.txt package.json.txt

dbaeumer commented 8 years ago

@MartinHaeusler the problem is that most of the properties in the tsconfig.json file are not supported by the 'native' tsc compiler. I tried your example and compiling it with the tsc compiler from the node_modules folder and it fails as well.

error TS6053: File 'P:/mseng/VSCode/Playgrounds/bugs/10042/src/**/*.ts' not found.
error TS6053: File 'P:/mseng/VSCode/Playgrounds/bugs/10042/src/**/*.tsx' not found.
error TS6053: File 'P:/mseng/VSCode/Playgrounds/bugs/10042/typings/**/*.ts' not found.
dbaeumer commented 8 years ago

Since you are using a special version of TS (the unofficial 2.0.0 version) you need to let VS Code know about this as well. You can do so by using the following setting:

    "typescript.tsdk": "./node_modules/typescript/lib"

This makes a simple ts file work for me:

capture

MartinHaeusler commented 8 years ago

@dbaeumer: Yes we are using typescript 2.0.0. I was wondering how to tell vscode which version to use but I could not find it anywhere in the documentation. I will try this as soon as I get back into the office, thanks a lot!

wclr commented 8 years ago

adding "typescript.tsdk": "./node_modules/typescript/lib" in .vscode/settings.json works :+1: