microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.08k stars 12.5k forks source link

Can not find global types when the globa types are installed in a subdirectory #35336

Closed b1zzu closed 4 years ago

b1zzu commented 4 years ago

Steps to Reproduce:

  1. Create a new project that looks like this:
    examples/
    foo/
     node_modules
       @types/
         jest/
     test/
       bar.test.ts
     jest.config.js
     tsconfig.json # this is extending the parent one tsconfig
     package.json
    node_modules/
    tsconfig.json
    package.json
  2. Open the project in vscode
  3. vscode will show errors like this:

    image

    in bar.test.ts

    but if I cd into the foo example and I run the tests npm test I will not have any typescript error

    also if I remove extends from the tsconfig.json the error will disappear

Is also possible to reproduce this issue by using this project: https://github.com/aerogear/graphql-testx

Does this issue occur when all extensions are disabled?: Yes

mjbvz commented 4 years ago

I can't repo this in the following case:

  1. Open the root of https://github.com/aerogear/graphql-testx
  2. Npm i in root and under examples/offix/test/
  3. Open examples/offix/test/offline.test.ts in VS Code
Screen Shot 2019-11-25 at 2 31 54 PM

Can you please share repo steps using the linked to repo?

b1zzu commented 4 years ago

Hi @mjbvz, thanks to reaching me out, I played with the project in the latest days and I found out that the offline.test.ts was not included in any tsconfig.json but because I was using ts-node the code was working, I've fixed it in some of the latest versions, this is probably the reason why you can't reproduce it.

It should be possible to reproduce it using this commit: https://github.com/aerogear/graphql-testx/tree/217a98ace795454eb7b281f4d635daba4493eea7

but at this point, I don't know whatever to still consider it a bug.