Skip to content

VS 2017 RC solution analysis does not respect tsconfig.json "types" property (shows errors) #12330

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

Closed
jasonswearingen opened this issue Nov 17, 2016 · 7 comments · Fixed by #12341
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@jasonswearingen
Copy link

TypeScript Version: VS 2017 RC, Community Edition

Code
open a project that uses the tsconfig.json "types" property, such as

    "types": ["node", "mocha"],

and vs 2017 RC shows errors such as

Error	TS2307	Cannot find module 'assert'.	xlib (tsconfig project)	C:\repos\stage4\xlib\src\logging.ts	12	Active

Expected behavior:
tsc compiles the project fine. also opening the project in VS2015 with NodeJs tools works fine.

Actual behavior:
vs 2017 RC shows intellisense errors in the error list. building ctrl-shift-b works fine and no errors are shown.

Repo Steps*
download the xlib project from https://github.com/Novaleaf/xlib and open it in VS2017 RC Community Edition.

@jasonswearingen
Copy link
Author

UPDATE

removing the following line from tsconfig.json removes the error from solution analysis

"typeRoots":[]

however that enables global inclusion of all @types which caused problems with nested projects before. I will investigate and see if the new version resolves these other issues.

@jasonswearingen
Copy link
Author

removing typeRoots is an effective workaround.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 17, 2016

well.. typeRoots were empty so not types were inferred. so the behavior you are seeing is correct. please see www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types for more details.

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Nov 17, 2016
@mhegazy mhegazy closed this as completed Nov 17, 2016
@jasonswearingen
Copy link
Author

i explicitly had the types property set, and it works using the tsc commandline compiler.

only vs 2017 built-in solution analysis chokes. but if you are fine with functional discrepancies, okay i guess.

@mhegazy mhegazy reopened this Nov 18, 2016
@mhegazy mhegazy removed the Working as Intended The behavior described is the intended behavior; this is not a bug label Nov 18, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Nov 18, 2016

We should look why there is a difference in behavior there. but this configuration does not look right. you are saying include "node" and "mocha" from "no where".

@jasonswearingen
Copy link
Author

from what I understand, by default the compiler will include all d.ts files it can find. adding the typeRoots restricts this to a certain path, and adding types forces that only certain definitions will be included by default.

all definitions explicitly loaded in code are loaded normally regardless.

so my project has type definitions for node and mocha but they are never explicitly loaded anywhere in my code.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 18, 2016

from what I understand, by default the compiler will include all d.ts files it can find

this is not accurate. all declaration files under typeRoots is what is included if types is not specified. if types is specified, only these are loaded.

@vladima vladima added the Fixed A PR has been merged for this issue label Nov 18, 2016
@vladima vladima added this to the TypeScript 2.1.3 milestone Nov 18, 2016
@vladima vladima added the Bug A bug in TypeScript label Nov 18, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
3 participants