You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Triple-slash reference affects all files instead of just the one file that contains it. #19978
Expected behavior:
Types from mocha are only available to the test ts file that include this triple-slash reference.
Actual behavior:
Types from mocha are available to all the ts files in the project, including both prod code and test code.
This is unexpected. How do we prevent Mocha test types from accidentally getting into prod code?
We're having the same problem with Jest, which declares even more ambient definitions than mocha: If one unit test does /// <reference types="mocha" />, then all the product code can suddenly access these definitions.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Activity
octogonz commentedon Nov 13, 2017
We're having the same problem with Jest, which declares even more ambient definitions than mocha: If one unit test does
/// <reference types="mocha" />, then all the product code can suddenly access these definitions.mhegazy commentedon Nov 14, 2017
/// <reference types="mocha" />is a global directive. it is an alias to--typesin your tsconfig.json or on the commandline.What
mochadoes is it adds declarations to the global scope, and there is no way to tease out what a global means in one module and not the other..My recommendation here is to have your tests in a separate compilation, and they would include
mocha.octogonz commentedon Nov 14, 2017
If we want VS Code IntelliSense for the unit tests, does that mean we need to create a separate package.json and/or tsconfig.json file?
Ian Clanton-Thuon (@iclanton)
mhegazy commentedon Nov 14, 2017
tsconfig.jsonis all you needtypescript-bot commentedon Nov 29, 2017
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.